I'm evaluating the pro grid for the company I work for and we have a big requirement that I haven't been able to solve yet.
On most of our pages where we have the grids we also have the functionality to build more complex search filters. This is not part of the grid and is handles completely seperated. However, we want to be able to send along an id (stored in a hidden field) whenever you do a filtering in the grid.
Our code is done in MVC and the filtering is done via JSON remotely.
I've managed to get the grid to call this function:
public ActionResult GetValues(int pq_curPage, int pq_rPP, string pq_sort, string pq_filter)
It returns the result correctly.
This is my testgrid so far:
$(function () {
function pqDatePicker(ui) {
var $this = $(this);
$this
.css({ zIndex: 3, position: "relative" })
.datepicker({
yearRange: "-20:+0", //20 years prior to present.
changeYear: true,
changeMonth: true,
showButtonPanel: true,
onClose: function (evt, ui) {
$(this).focus();
}
});
//default From date
$this.filter(".pq-from").datepicker("option", "defaultDate", new Date("01/01/1996"));
//default To date
$this.filter(".pq-to").datepicker("option", "defaultDate", new Date("12/31/1998"));
}
var dataModel = {
location: "remote",
sorting: "remote",
dataType: "JSON",
method: "GET",
url: "Home/GetValues",
getData: function (dataJSON) {
var data = dataJSON.data;
return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: data };
}
}
var obj = {
flexWidth: true,
editable: false,
title: "ParamQuery Test Grid",
pageModel: { type: "remote", rPP: 10, strRpp: "{0}" },
filterModel: { on: true, mode: "AND", header: true },
dataModel: dataModel
};
obj.colModel = [
{
title: "First Name", width: 400, dataIndx: "FirstName",
filter: { type: 'textbox', condition: 'begin', listeners: ['change'] }
},
{
title: "Last Name", width: 400, dataIndx: "LastName",
filter: { type: 'textbox', condition: 'begin', listeners: ['change'] }
},
{
title: "Age", width: 50, dataIndx: "Age",
filter: { type: 'textbox', condition: 'begin', listeners: ['change'] }
},
{
title: "Start Date", width: 100, dataIndx: "StartDate",
filter: { type: 'textbox', condition: "between", init: pqDatePicker, listeners: ['change'] }
},
{
title: "Male", width: 100, dataIndx: "IsMale", dataType: "bool", align: "center",
filter: { type: "checkbox", subtype: 'triple', condition: "equal", listeners: ['click'] }
},
{
title: "Department", width: 100, dataIndx: "Department",
filter: {
type: "select",
condition: 'equal',
prepend: { '': '--Select--' },
valueIndx: "DepartmentId",
labelIndx: "Department",
listeners: ['change']
}
}
];
$("#testGrid").pqGrid(obj);
});
So, how would I send along an extra parameter when filtering?