分组导出JqGrid

时间:2013-05-22 07:24:18

标签: javascript jquery jqgrid

我想将我的jqgrid导出到excel。这个代码适用于基本的jqgrid,但我想导出分组jqgrid与每个组的摘要。我无法导出所有数据。未导出的每个组的摘要。并且我无法在javascript中获取每个组的摘要以手动发送到服务器。

我只在服务器端使用Jqgrid客户端我只使用表单提交生成excel所有数据发回服务器以生成excel。

这是我的网格: 读取边框数据不在Excel中导出。

enter image description here

这是我的Excel文件

enter image description here

和javascript中的我的导出功能是:

function fun(){alert("call"); 

//options = ['xmlstring','grid'];
//jQuery("#list2").jqGrid('jqGridExport',options);
//userdata = jQuery("#list2").getUserData;

 numberOfRecords = $("#list2").getGridParam("records");

var mya=new Array();
    total = jQuery("#list2").jqGrid('footerData','get'); // to get the last footer data
    obj2 = jQuery("#list2").jqGrid('getCol','amount','array','sum');
    group = jqobj.groupField;

mya=jQuery("#list2").getDataIDs();  // Get All IDs
var data=jQuery("#list2").getRowData(mya[0]);     // Get First row to get the labels
var colNames=new Array();  
var ii=0;
var html="";
for (var i in data){colNames[ii++]=i;
html = html +i+"\t";}    // capture col names
html = html + "\n";
for(i=0;i<mya.length;i++)
    {
        data=jQuery("#list2").getRowData(mya[i]); // get each row
        for(j=0;j<colNames.length;j++)
            {
                html=html+data[colNames[j]]+"\t"; // output each column as tab delimited
            }
        html=html+"\n";  // output each row with end of line

    }

for(j=0;j<colNames.length;j++)
{
    html=html+total[colNames[j]]+"\t"; // output each column as tab delimited
}   

html=html+"\n";  // end of line at the end
//document.forms[0].csvBuffer.value = csv
alert(html);
document.forms[0].csvBuffer.value=html;
document.forms[0].method='POST';
document.forms[0].action='csvExport.jsp';  // send it to server which will open this contents in excel file
document.forms[0].target='_blank';
document.forms[0].submit();

}

0 个答案:

没有答案
相关问题