Hi All,
I am not able to apply the filter to grid after using the below code in jquery script.
var myfilter = { groupOp: "AND", rules: []};
myfilter.rules.push({field:"Customer",op:"cn",data:"Cross"});
var grid = $("#list1");
grid.jqGrid({
search:true,
postData: { filters: myfilter}
//JSON.stringify(myfilter)
});
$('#list1').trigger("reloadGrid",[{jqgrid_page:1}]);
Anyone can help on this..
I am using the premium version.
Regards
Chandru
Hello Chandru,
Try using this code …
<script>
var myfilter = { groupOp: "AND", rules: []};
myfilter.rules.push({field:"Customer",op:"cn",data:"Cross"});
var opts = {
search:true,
postData: { filters: myfilter}
};
</script>
…
<div style="margin:10px">
<?php echo $out?>
</div>
The var opts, override existing object's properties if any, when defined in this way.
Hi Abu,
I have tried your option but i didnt succeed and in firebug it says like
_search true
filters[groupOp] AND
filters[rules][0][data] Cross
filters[rules][0][field] Customer
filters[rules][0][op] cn
Gives me error like "500 Internal Server Error -"
I want to apply filter and want to reload the grid using jquery.
or how can we pass columns and values to search option using jquery.
Regards
Chandru
Hi Abu,
I am looking for something like this in php grid.
you can check this below demo
http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridFiltered.htm
is it possible that can we use the code like below in phpgrid.
$("#search").click(function() {
var searchFiler = $("#filter").val(), grid = $("#list"), f;
if (searchFiler.length === 0) {
grid[0].p.search = false;
$.extend(grid[0].p.postData,{filters:""});
}
f = {groupOp:"OR",rules:[]};
f.rules.push({field:"name",op:"cn",data:searchFiler});
f.rules.push({field:"note",op:"cn",data:searchFiler});
grid[0].p.search = true;
$.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
grid.trigger("reloadGrid",[{page:1,current:true}]);
});
Regards
Chandru
Hi Abu,
this script worked great for me..
$("#search").click(function() {
var searchFiler = $("#filter").val(), grid = $("#list"), f;
if (searchFiler.length === 0) {
grid[0].p.search = false;
$.extend(grid[0].p.postData,{filters:""});
}
f = {groupOp:"OR",rules:[]};
f.rules.push({field:"name",op:"cn",data:searchFiler});
f.rules.push({field:"note",op:"cn",data:searchFiler});
grid[0].p.search = true;
$.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
grid.trigger("reloadGrid",[{page:1,current:true}]);
});
Regards
Chandur
Is this feature available in the free version too? cuz I can't seem to get it to work and I always get this error:
Fatal error: Call to undefined function array_is_associative() (Error is in the jqgrid_dist.php on line 9)
this is the code I'm using:
<script type="text/javascript">
//var searchFiler = $("#Search").val();
var searchFiler = 'Admin';
var f;
f = { groupOp: "AND", rules: [] };
f.rules.push({ field: "Name", op: "cn", data: searchFiler });
//f.rules.push({field:"note",op:"cn",data:searchFiler});
var opts = {
search:true,
postData: { filters: f}
};
</script>
And I did place it before the echo of the $out