Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选中复选框时将jqgrid数据导出到excel_Javascript_Jquery_Asp.net Mvc_Jqgrid - Fatal编程技术网

Javascript 选中复选框时将jqgrid数据导出到excel

Javascript 选中复选框时将jqgrid数据导出到excel,javascript,jquery,asp.net-mvc,jqgrid,Javascript,Jquery,Asp.net Mvc,Jqgrid,我已经从MVC控制器绑定了jqGrid,下面是我的jqGrid代码。我想将选中的复选框行数据导出到csv,我已经查看了所有代码,但每个代码都提供了示例本地数据,但我正在从服务器绑定到jqGrid,所以当我在jqGrid中选择复选框行并单击导出按钮时,整行都应该导出到csv,有人能找到解决方案吗 $'jQGrid'.jQGrid{ search: true, multiboxonly: true, colNames: ["PayloadCorrela

我已经从MVC控制器绑定了jqGrid,下面是我的jqGrid代码。我想将选中的复选框行数据导出到csv,我已经查看了所有代码,但每个代码都提供了示例本地数据,但我正在从服务器绑定到jqGrid,所以当我在jqGrid中选择复选框行并单击导出按钮时,整行都应该导出到csv,有人能找到解决方案吗

$'jQGrid'.jQGrid{

        search: true,
        multiboxonly: true,
        colNames: ["PayloadCorrelationId", "Export", "Asset", "DateReported", "ErrorType", "Error", "Latitude", "Longitude", "Payloadurl"],

        colModel: [
            { name: 'CorrelationId', jsonmap: 'CorrelationId', hidden: true, width: 2 },
            { name: "", editable: true, edittype: "checkbox", width: 45, sortable: false, align: "center", formatter: "checkbox", editoptions: { value: "1:0" }, formatoptions: { disabled: false } },
            { name: 'Device', jsonmap: 'Device', width: 60 }, { name: 'DateReported', jsonmap: 'DateReported', width: 100 },
              { name: 'ErrorType', jsonmap: 'ErrorType', width: 85 },
       { name: 'Error', jsonmap: 'Error', width: 140 },
       { name: 'Latitude', jsonmap: 'Latitude', width: 80 }, { name: 'Longitude', jsonmap: 'Longitude', width: 80 },
       { name: 'Payloadurl', jsonmap: 'Payloadurl', width: 180, formatter: 'link' }],

        cellEdit: true,
        pager: jQuery('#divpager'),
        rowList: [5, 20, 50, 100],
        rowNum:5,
        sortorder: "desc",
        datatype: 'json',
        width: 900,
        height: 'auto',
        viewrecords: true,           
        mtype: 'GET',
        gridview: true,
        loadonce: true,
        url: '/DataIn/DataInSearchResult/',

        emptyrecords: "No records to display",
        onSelectRow: true,
        onSelectRow: function (id, status) {
            var rowData = jQuery(this).getRowData(id);
            configid = rowData['CorrelationId'];
            alert(configid);
            // Add this    
            var ch = jQuery(this).find('#' + id + ' input[type=checkbox]').prop('checked');
            if (ch) {
                jQuery(this).find('#' + id + ' input[type=checkbox]').prop('checked', false);
            } else {
                jQuery(this).find('#' + id + ' input[type=checkbox]').prop('checked', true);
            }
            // end Add
            rowChecked = 1;
            currentrow = id;
        },
        loadComplete: function () {
            var ts = this;
            if (ts.p.reccount === 0) {
                $(this).hide();

            } else {
                $(this).show();                    
                $("#lblTotal").html($(this).getGridParam("records") + " Results");
            }
        }

    });

只是澄清一下,点击时必须有任何按钮,csv将从选中的复选框中生成。如果是这样,则循环网格数据以过滤出选中的行。您可以在触发按钮事件时轻松循环网格数据。根据结果数据创建csv