Retrieve all the rows from the server site and then export to excel with the 'rows' parameter.
// export with customized rows
$('#dg').datagrid('toExcel', {
filename: 'datagrid.xls',
worksheet: 'Worksheet',
caption: 'Caption',
fields: ['itemid','productid'],
rows: rows,
footer: [{
productid: 'Summary',
listprice: 30
},{
productid: 'Summary',
listprice: 40
}]
});