1
Help for ParamQuery Grid (free version) / Re: First value in Select List for filter not selected by defailt
« on: July 29, 2016, 04:28:42 am »
I am doing it like this. Once you set the value, you need to trigger the change event for the filter. There may be a cleaner way to do it though.
Code: [Select]
function fncPopulateGrid(oData){
// Load the data into the grid.
$oGrid.pqGrid("option", "dataModel.data", oData);
// Set up the recordsets for our three selection box filters.
var oColumnModel = $oGrid.pqGrid("option", "colModel");
oColumnModel[2].filter = { type: "select", condition: "equal", prepend: {'': ""}, valueIndx: "PaymentPeriod", labelIndx: "PaymentPeriod",
listeners: ['change'], options: $oGrid.pqGrid("getData", { dataIndx: ["PaymentPeriod"]})};
oColumnModel[3].filter = { type: "select", condition: "equal", prepend: {'': ""}, valueIndx: "AgencyName", labelIndx: "AgencyName",
listeners: ['change'], options: $oGrid.pqGrid("getData", { dataIndx: ["AgencyName"]})};
oColumnModel[4].filter = { type: "select", condition: "equal", prepend: {'': ""}, valueIndx: "PayStatus", labelIndx: "PayStatus",
listeners: ['change'], options: $oGrid.pqGrid("getData", { dataIndx: ["PayStatus"]})};
$oGrid.pqGrid("option", "colModel", oColumnModel);
// Let's set the default value fo "Pay Status" to "Released" if appropriate.
if($.inArray('Released', oColumnModel[4].filter.options !== -1)){
oColumnModel[4].filter.value = 'Released';
}
// Now that the grid is loaded with data and the filters are set up, let's update the client's view.
$oGrid.pqGrid("refreshDataAndView");
// Trigger the filter event for the "PayStatus" column since we are re-selecting a value.
$("select[name='PayStatus']" ).change();
}