jqgrid, export to excel (with current filter post data) in an asp.net-mvc site

前端 未结 3 1137
执笔经年
执笔经年 2021-01-17 03:53

i have an asp.net-mvc web page and i am using jqgrid on the front end. i want to have an export to excel button that will export the current set of data (based on the curr

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 04:33

    I succeed to make filtered export, taking inspiration by above @simpatric greg solution.

    I set one session variable for each grid parameter, when data is requested and then passing again them to the excel export service. Greg's solution can work with asp.net MVC, which is ok for the main question. The following solution could be used with standard pure js jqgrid too:

    CONTROLLER GRID ACTION

            ...
          Session["jqsidx"] = sidx; 
          Session["jqsord"] = sord; 
          Session["jqpage"] = page; 
          Session["jqrows"] = rows; 
          Session["jq_search"] = _search; 
          Session["jqfilters"] = filters; 
          ....
    

    RECALLED INSIDE OF EXCEL EXPORT ACTION ^^

     string sidx = Session["jqsidx"] as String;
     string sord = Session["jqsord"] as String;
     int? page = Session["jqpage"] as Nullable;
     int? rows = Session["jqrows"] as Nullable;
     bool? _search = Session["jq_search"] as Nullable;
     string filters = Session["jqfilters"] as String;
    
    var query = myqueryservice.getGridData(sidx, sord, (int)page, (int)rows, (bool)_search, filters, urlparams).ToList();
    ...
    

    I hope this may help for other people having the same problem with standard jqgrid.

提交回复
热议问题