Search code examples
jqgridexportexport-to-excelcalculated-columns

How do I exportToExcel a calculated column in jqgrid? exportToExcel virtual column


The excel export for col3 in the jsfiddle jqgrid below contains no data.

Does anyone know how to get the data to exportToExcel for virtual or calculated columns?

http://jsfiddle.net/carboncope/7rcsaepo/15/

$("#grid").jqGrid({
datatype: "local",
data: mydata,
height: 250,
width: 500,
colNames: ['id', 'col1', 'col2', 'col3'],
pager: "#gridpager",
colModel: [{
        name: 'id',
        index: 'id',
        width: 60,
    },
    {
        name: 'col1',
        index: 'col1',
        width: 50,
    },
    {
        name: 'col2',
        index: 'col2',
        width: 50
    },
    {
        name: 'col3',
        index: 'col3',
        width: 50,
        formatter: function(cellvalue, options, rowObject) {
            var showValue = (parseInt(rowObject.col1) + parseInt(rowObject.col2));
            if (showValue) {
                if (options.isExported) {
                    return showValue;
                } else {
                    return showValue;
                }
            } else {
                return 'novalue';
            }
        },
    }
],
caption: "exportToExcel Calculated Column",

});


Solution

  • The reason for this was a bug in the code. The problem is fixed and the fixed code can be get from GitHub