EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: evertonsena on April 19, 2012, 12:43:23 PM



Title: Filter remote on a 'combogrid'
Post by: evertonsena on April 19, 2012, 12:43:23 PM
How to filter in a remote 'combogrid' merging with the 'queryParams'?

I thank you!


Title: Re: Filter remote on a 'combogrid'
Post by: stworthy on April 19, 2012, 06:31:18 PM
Set 'mode' property to 'remote' to make the combogrid be able to filter data on remote server. At the remote filter mode, the text users typed will be sent to server as a parameter named 'q'. If the 'queryParams' of grid is defined, it will also be sent to server. Write some code to retrieve the 'q' parameter and then return some new data set to the browser:

Code:
String q = request.getParameter("q");
// do some query from database
// return data set


Title: Re: Filter remote on a 'combogrid'
Post by: evertonsena on April 24, 2012, 02:02:13 PM
thanks for the answer! :)

The point is that 'queryParams' defined on the grid is not passed to the server. Only the parameters 'q', 'page' and 'rows' are sent.

Understand me? ???


Title: Re: Filter remote on a 'combogrid'
Post by: stworthy on April 25, 2012, 12:38:33 AM
Try the following code to fix this issue:

Code:
(function($){
var oldQuery = $.fn.combogrid.defaults.keyHandler.query;
$.fn.combogrid.defaults.keyHandler.query = function(q){
var target = this;
var opts = $(target).combogrid('options');
var grid = $(target).combogrid('grid');
grid.datagrid('options').onBeforeLoad = function(param){
if (opts.onBeforeLoad.call(target, param) == false) return false;
$.extend(param, opts.queryParams);
}
oldQuery.call(this, q);
}
})(jQuery);


Title: Re: Filter remote on a 'combogrid'
Post by: evertonsena on April 25, 2012, 07:03:28 AM
Perfect! It worked perfectly! Thanks for your quick response and taking advantage of the space you want congratulation by the excellent work. I use to develop a project for my learning and I meet 100% right. Follow the example of the application using almost all components: www.evertonsena.com/login

 :D  ;D :D


Title: Filter remote on a 'combogrid'
Post by: dearsh on August 10, 2013, 11:56:39 PM
how to use that code ?
I have problem with combogrid filter in mode remote. The combogrid just view form tabel but failed to filter.
i think the problem is params not send.
I was download and try file demo easyui-form5-demo but failed to filter data like in demo online.

i don't know where is the problem. Please help me.

Thx
dearsh jaki