The below example demonstrates remote data filtering.
A filter row UI is added below header row when filterModel.header = true
Filter request is sent remotely when filterModel.type = 'remote'
Filter request is sent to server as GET or POST request depending upon dataModel.method
option value.
It's better to send filter requests as POST data especially when filter requests become too big.
Inbuilt filter conditions are sufficient for most use cases, however new filter custom conditions can be easily added by making some local and remote changes.
When new filter condition is defined as below by extending pq.filter.conditions
, it becomes available in the filter condition drop down menu.
The following new filter condition is added as "Not between" in the drop down menu.
pq.filter.conditions.notbetween = { filter: { type: 'textbox2', //type of UI control. init: pq.filter.datepicker //use inbuilt init callback for jQueryUI datepicker or any other control of your choice. }, number: 1, date: 1 //condition applicable to number and date dataType } //define localization string for custom condition. $.paramquery.pqGrid.defaults.strConditions.notbetween = "Not between";
The comparator for this custom condition is added as new method named _notbetween
in the FilterHelper
class in the remote script.
C#, PHP and Java custom comparator methods are written similar to other comparator methods in the class.
Note: Every condition method begins with underscore "_" in the FilterHelper class.
//custom condition notbetween. public static void _notbetween(String dataIndx, String varName, List<String> fcrule, List<object> param, String value, String value2) { fcrule.Add("(" + dataIndx + "<=@" + varName + " OR " + dataIndx + ">=@" + varName + "_2)"); param.Add(new SqlParameter(varName, value)); param.Add(new SqlParameter(varName + "_2", value2)); }