简体   繁体   English

jqGrid导出数据AJAX

[英]jqGrid export data AJAX

I am trying to export all of the data from a grid. 我正在尝试从网格导出所有数据。 I wrote a function that does all of the exporting to excel. 我写了一个函数,可以完成所有导出到excel的操作。 I just need to get the data from the grid. 我只需要从网格中获取数据。

I have it working using: 我有使用它的工作:

$("#grid").jqGrid('excelExport',{"url":"gridExport.php"});

I have a jquery click function that runs that and it works but it redirects the gridExport.php. 我有一个运行它的jquery click函数,它可以工作,但是它重定向了gridExport.php。 I am trying to get this to open without moving the page. 我正在尝试打开此页面而不移动页面。

I tried to just write my own jquery post function to the gridExport.php but I am not getting all of the params I need from the grid. 我试图将自己的jquery post函数编写到gridExport.php中,但是我没有从网格中获取我需要的所有参数。 I am assuming I can manually grab all the params I need and send them to the gridExport.php but I am not 100% how to do that and/or if there is an easier way to do it. 我假设我可以手动获取所需的所有参数并将其发送到gridExport.php,但是我不是100%如何做到这一点和/或是否有更简单的方法来做到这一点。

Any help on this would be great. 任何帮助都会很棒。

Thanks! 谢谢!

UPDATE: 更新:

I figured out a way to make this work. 我想出了一种方法来使这项工作。 I just used my own jquery post function and got the paramas I needed from the grid and passed it to my processing page via the post function. 我只是使用了自己的jquery post函数,并从网格中获取了所需的paramas,并通过post函数将其传递给了我的处理页面。 I just needed the postData and colModel form my grid. 我只需要将postData和colModel形成网格即可。 This is how I got the params and put them into JS variables: 这就是我获取参数并将其放入JS变量的方式:

        var gParam = $("#grid").jqGrid('getGridParam','postData');
        var gParamCol = $("#grid").jqGrid('getGridParam','colModel');

I figured out a way to make this work. 我想出了一种方法来使这项工作。 I just used my own jquery post function and got the paramas I needed from the grid and passed it to my processing page via the post function. 我只是使用了自己的jquery post函数,并从网格中获取了所需的paramas,并通过post函数将其传递给了我的处理页面。 I just needed the postData and colModel form my grid. 我只需要将postData和colModel形成网格即可。 This is how I got the params and put them into JS variables: 这就是我获取参数并将其放入JS变量的方式:

    var gParam = $("#grid").jqGrid('getGridParam','postData');
    var gParamCol = $("#grid").jqGrid('getGridParam','colModel');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM