I am using PQGrid in an MVC app that makes use of column filters. More specifically, a dropdown list filter that listens for a change in selected value. When a new value is selected, an ajax call is triggered and the filter is appended to my SQL query on the server side (exactly as prescribed in the demo for Filters --> Remote Filter). The raw filter info being sent back to the server from the grid looks like this:
"{\"mode\":\"AND\",\"data\":[{\"dataIndx\":\"ObjectName\",\"value\":\"<text goes here>\",\"condition\":\"equal\",\"dataType\":\"string\",\"cbFn\":\"\"}]}"
This string gets sent to the server to be deserialized and then used to construct the query predicate (per the PQGrid Filter documentation).
I am trying to re-create this output for another method that is triggered by a different event in the DOM. I've tried to create a JSON object one the event is fired that replicates the string above, but it does not work. It generates an "Invalid JSON primitive" error.
Rather than re-create the wheel, I believe there is a way to get the column filter object and values that behaves exactly as the built-in. Here's what I've tried:
var colM = $("#grid_students").pqGrid("option", "colModel");
(test 1) var filter = colM[3].filter;
(test 2) var filter = colM[3].filter.value;
I've tried to send the entire object, but it's entirely too much (this can be seen in Chrome developer tools pretty clearly). I've also tried getting the currently selected value of the filter and alter the LINQ query to no avail.
Please advise.
Here is how the grid is defined:
var obj = {
width: 1200,
height: 800,
wrap: false,
hwrap: false,
editable: false,
showTop: true,
showBottom: true,
collapsible: false,
showHeader: true,
resizable: true,
columnBorders: true,
rowBorders: true,
flexHeight: false,
virtualX: false,
sortable: true,
numberCell: { show: true },
filterModel: { mode: "AND", header: true },
scrollModel: { autoFit: true, pace: 'optimum' },
selectionModel: { type: 'row', mode: 'single' },
toolbar: {
items: items
},
colModel: columns...