c# - jqGrid: Help displaying current search to user. -
i have jqgrid , need able display current search that's being performed on grid. use navgrid give users options filter through what's been pulled , i'd able show users current filters being applied data. have label on page , javascript grabs current queries , displays onsearch:
function setcurrentfilters () { var currentfilters = $('#datamanagementgrid').getgridparam("postdata").filters; document.getelementbyid("lblcurrentfilters").innerhtml = currentfilters; }
it displays json:
{"groupop":"and","rules":[{"field":"isactive","op":"eq","data":"true"},{"field":"lastmodifiedby","op":"cn","data":"cheese"}]}
my question is, there better route? or should work json?
you can parse json , read field name/value , show in html. idea, not solution though :
function setcurrentfilters () { var currentfilters = $('#datamanagementgrid').getgridparam("postdata").filters; var htmlstring=''; var data = $.parsejson(currentfilters); $.each(data.rules, function(idx, obj) { htmlstring += obj.field + ' ' + obj.op + ' ' + obj.data + '<br />; }); document.getelementbyid("lblcurrentfilters").innerhtml = currentfilters; }
apply logic in loop check kind of operator there , want show i.e. eq ' = ' etc.
Comments
Post a Comment