use a common function. Since filter dropdown inherits the API of pqgrid, dataModel.postData can be used to send table name and column field name.
function remoteOptions(table){
return function (ui) {
ui.obj.dataModel = {
location: 'remote',
url: '/pro/customers/names',
postData: {table: table, di: ui.column.dataIndx },
getData: function (response) {
var val = ui.column.filter.crules[0].value || [],
di = ui.column.dataIndx,
data = response.data;
data.forEach(function (rd) {
if (val.indexOf(rd[di]) >= 0) {
rd.selected = true;
}
})
return { data: data };
}
}
};
}
And in the column definition, link the common function to filter.selectGridObj
{ title: "Customer Name", width: 120, dataIndx: "ContactName",
filter: {
crules: [{ condition: 'range' }],
selectGridObj: remoteOptions('some_table')
}
},