0

How to get form data while column filter in jqgrid

I have used external check box also using the updated answer code from Link

I have used the working example reference Link

jQuery("#list451").jqGrid({ 
url:'getList.php?mode=result_list', 
datatype: "json",
height: 255, 
width: 600, 
colNames:['Index','Name', 'Code','Result'], 
colModel:[
{name:'item_id',index:'item_id', width:65, sorttype:'integer',searchoptions:{sopt:['eq','ne','le','lt','gt','ge']}},
{name:'item',index:'item', width:150, sorttype:'string',searchoptions:{sopt:['eq','bw','bn','cn','nc','ew','en']}},
{name:'item_cd',index:'item_cd', width:100} ,
{name:'result',index:'result', width:100,sorttype:'string',searchoptions:{sopt:['eq','ne']} ], 
rowNum:50, 
rowTotal: 200,
rowList : [20,30,50], 
loadonce:false, 
mtype: "GET", 
rownumbers: true,
rownumWidth: 40, 
gridview: true, 
pager: '#pager451', 
sortname:'item_id', 
viewrecords: true, 
sortorder: "asc", 
caption: "Loading data from server at once" });
jQuery("#list451").jqGrid('filterToolbar',{searchOperators : true});

External check box code Actions in script

 //Pass fail code check box
            $("#pass").change(function() {
                var f = {groupOp:"AND",rules:[]};
                if($("#pass").is(':checked')) {
                   f.rules.push({field:"result",op:"eq",data:"pass"});
                }

                grid[0].p.search = f.rules.length>0;
                $.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
                grid.trigger("reloadGrid",[{page:1}]);
            });

Check box html Code is below

<input type="checkbox" name="pass" id="pass">Pass

In above pass/fail code working for check box click to sort the pass/fail in grid.

I want if pass check box checked then i will enter item name in search box and choose the not equal search operation after enter to am not getting the pass check box value in server side. I got a search box value and search operators but i am not get the pass check box value.

I want pass check box value in server side.Please help me

Community
  • 1
  • 1
Krishna
  • 739
  • 1
  • 10
  • 29

1 Answers1

2

I'm not sure that I correctly understand your problem. If you use remote datatype (like datatype: "json" in your code) and without usage of loadonce: true option then the server is responsible to return filtered data. The server get filters parameter. It's JSON formatted string in the format described in the documentation. If you implement decoding of filters in the format you can use any searching/filter functionality of jqGrid (advanced searching, filter toolbar etc).

If you have problem to implement filtering based on the standard filters parameter you can just send the information about the filters in free format which you can define yourself. See the answer for more details. In case of the demo from the answer one have checkboxes with ids cb_pending, cb_processing and cb_delivered. If you would add postData parameter in for example the following form

postData: {
    pending: function () { return $("#cb_pending").is(':checked'); },
    processing: function () { return $("#cb_processing").is(':checked'); },
    delivered: function () { return $("#cb_delivered").is(':checked'); }
}

then pending, processing and delivered parameters will be added to the server every time.

Alternatively you can use jQuery.serialize or jQuery.serializeArray to get all values of one HTML form at once instead of queering every checkbox separately by id.

Community
  • 1
  • 1
Oleg
  • 217,934
  • 30
  • 386
  • 757
  • Thanks a lot Oleg..........Its working fine......i had solved more number of issues with your help.... – Krishna Sep 23 '14 at 14:19