|
Title: enableFilter and default value Post by: rezzonico on June 03, 2015, 01:24:50 AM Hi all,
in my datagrid I use "enableFilter" to do some search. All works as expected. I only have the following question. Suppose that in "enableFilter" I define the following values: data: [ {value:'0', text:'No'}, {value:'1', text:Yes'} ] When I load the datagrid for the first time, I need that the filter is set to 'Yes'. Is it possible ? Thanks Miche Title: Re: enableFilter and default value Post by: jarry on June 03, 2015, 08:04:45 AM Please set the 'filterRules' property to initialize the filter rules when loading the data.
Code: $('#dg').datagrid({Title: Re: enableFilter and default value Post by: rezzonico on June 17, 2015, 06:07:54 AM Hi Jarry,
thanks a lot for your help. I have tryed your solution but without success. Please try the following example (this is your datagrid-filter.zip): http://195.144.40.170/AAA/index.html As you can see, when the datagrid is displayed for the first time, the value of the column "Status" is "All". My problem is to set the default value to "P". In order to do this I have added the following line: filterRules:[{ field:'status', op:'equal', value:'P' }] ... but it doesn't work. I am doing an error ? Regards. Miche Title: Re: enableFilter and default value Post by: jarry on June 17, 2015, 05:38:16 PM Please refer to this example http://jsfiddle.net/7gq0mboe/. It works fine. Make sure you are using the latest 'datagrid-filter.js' file, it can be downloaded from http://www.jeasyui.com/extension/datagrid_filter.php
Title: Re: enableFilter and default value Post by: rezzonico on June 17, 2015, 11:37:16 PM Hi Jarry,
thanks a lot for your help. After downloading the latest 'datagrid-filter.js' all works as expected. Regards. Miche Title: Re: enableFilter and default value Post by: gordis gmbh on July 23, 2015, 04:36:00 AM Hi all.
But there is an issue with this approach. The data in datagrid is loaded n-number of times! I have extended your fiddle example to demonstrate the same: http://jsfiddle.net/ov3zxqww/1/ (http://jsfiddle.net/ov3zxqww/1/) In case of remote url call this is terrible! Please help. It should be possible to - define a datagrid (set url, columns etc.) - enable custom filters (call enableFilter) - initialize datagrid with some filter rules (filterRules) and then load the data into datagrid. Thanks. Title: Re: enableFilter and default value Post by: jarry on July 24, 2015, 12:32:34 AM Please try to call 'enableFilter' method before loading data. The updated example is available from http://jsfiddle.net/ov3zxqww/2/
Title: Re: enableFilter and default value Post by: gordis gmbh on July 24, 2015, 02:13:24 AM Thanks Jarry for your reply.
Calling loaddata after enableFilter does solve the problem. Can you please give me a tip how can the data be loaded belatedly using an url? Title: Re: enableFilter and default value Post by: gordis gmbh on July 29, 2015, 03:46:21 AM OK, here is a solution for the question I asked in my earlier reply. Just in case someone else has the same issue...
Thanks Jarry for your reply. Calling loaddata after enableFilter does solve the problem. Can you please give me a tip how can the data be loaded belatedly using an url? In order to load the data using an url after calling enableFilter, you need to do the following: set the url option after calling enableFilter and then apply your filterRules by calling addFilterRule. Here an example: Code: // define edatagrid (don't set url option) Note: upon calling addFilterRule, the 'doFilter' gets triggered and the data is loaded. |