|
Title: How to makes Grid Filter on server side? Post by: stvhui on February 28, 2014, 10:53:34 PM Hello to you,
I'm newbie in learning EasyUI How to makes Grid Filter on server side? From the documentation and forum I learned to write as below : Code: <script type="text/javascript" src="datagrid-filter.js"></script> Genderid contains : M means Male F means Female The problem is : The genderid not passing its value to server side (crud.php) My Questions is : How to passing the filtered genderid to server side? Please correct me and show me its solution by an example. Thanks & Regards, Steven Title: Re: How to makes Grid Filter on server side? Post by: stworthy on March 01, 2014, 08:08:44 AM When enable remote filtering, the 'filterRules' parameter will be sent to server. The value looks like this:
Code: [{"field":"genderid","op":"equal","value":"M"}]Title: Re: How to makes Grid Filter on server side? Post by: stvhui on March 02, 2014, 11:15:10 PM Hello to you Stworthy,
Thanks for yr prompt reply. Facing to my cases, Lets says Genderid type as TEXT not COMBOBOX, the code as shown : var dg = $('#dg').datagrid({remoteFilter:true,type:'post',url:'crud.php'}); The Problems is : crud.php not recieved the typed text in Filter box, lets says I type M into filter box. I means M not passing into crud.php Would you mind show me an example for above cases? Please advice & thanks in advance Regards, Steven Title: Re: How to makes Grid Filter on server side? Post by: stvhui on March 03, 2014, 02:44:32 AM Hello to you Stworthy,
I'm using EasyUI 1.3.5 From Forum I found yr solution of How to passing/get filterbox value? - Filterbox editor type is TEXT, Let says I have typed character B on the filterbox var nameEditor = $('#tt').datagrid('getEditor',{index:index,field:'name'}); var nameValue = $(nameEditor.target).val(); // get name field value My Questions is how to show/display nameValue? I tried code as : alert(nameValue); The result is empty/nothing, the answer is I should get B Another example is : -Filterbox editor type is COMBOBOX, Let say I choose AMERICA var countryEditor = $('#tt').datagrid('getEditor',{index:index,field:'country'}); var countryValue = $(countryEditor.target).combobox('getValue'); // get country field value, notice that the editor type is combobox How to show/display countryValue? I tried code as : alert(countryValue); The result is AMERICA, but when post this value to crud.php, the crud.php cannot recieved the value Please advice and show me an example Thanks & Regards, Steven Title: Re: How to makes Grid Filter on server side? Post by: stworthy on March 03, 2014, 05:52:21 PM To enable remote filter, please set 'remoteFilter' to true. When doing filter, the 'rows','page' and 'filterRules' parameters will be sent to server. The 'filterRules' parameter describe all the filter rules, you need to decode it in your server code and build corresponding sql statement. The code snippets look like this:
Code: <?php Please refer to the attached example that achieves server side paging and filtering functionality. Title: Re: How to makes Grid Filter on server side? Post by: stvhui on March 03, 2014, 11:18:07 PM Hello to you Stworthy,
Thanks for an example and It's great to makes me more understanding its concept. Part of an example : $filterRules = isset($_POST['filterRules']) ? ($_POST['filterRules']) : ''; // $filterRules contains [{\"field\":\"productid\",\"op\":\"contains\",\"value\":\"gg\"},{\"field\":\"attr1\",\"op\":\"contains\",\"value\":\"dd\"}] Its format is quite strange because in every paramaters included "\" character at the end makes json_decode not works. So to solve it, I try to clean-up all the "\" character as shown below : Code: $filterRules = isset($_POST['filterRules']) ? ($_POST['filterRules']) : ''; My questions is, it is the proper way to clean-up all the "\" or buggy? Please advice and show me by code Regards, Steven |