ฉันมี Jqgrid ดังนี้:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:58404/JQGridHandler.ashx',
colNames: ['Property ID', 'Property Ref', 'Short Address', 'Scheme Code', 'Scheme Name', 'Property Type', 'Tenure Type', 'Status', 'Management Cost','Rent Charge Month','SC Charge Month'],
colModel: [
{ name: 'PropertyID', index: 'PropertyID', width: 70, align: "left", stype: 'text', sortable: true},
{name: 'PropertyType',width: 80},
{ name: 'TenureType', index: 'TenureType', width: 80, align: "center", sortable: true },
{ name: 'Status', index: 'Status', width: 75, align: "center", sortable: true },
],
ตารางใช้งานได้และเติมด้วย Json ที่ส่งคืนจาก URL อย่างไรก็ตาม ฉันกำลังพยายามใช้ตัวกรองแบบเลื่อนลงที่มีการเติมข้อมูลแบบไดนามิกในคอลัมน์ PropertyType และดูคำตอบของ Oleg ที่นี่: จะเพิ่มตัวกรองไดนามิกแบบเลื่อนลงโดยใช้ Jqgrid ได้อย่างไร
ฉันจึงได้เพิ่มฟังก์ชัน "beforeProcessing":
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data.rows, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
$(this).jqGrid("setColProp", 'PropertyType', {
stype: "select",
searchoptions: {
value: propertyValues
}
}).jqGrid('destroyFilterToolbar')
.jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
},
คำถามของฉันคือ ฉันจะส่งข้อมูลที่ส่งคืนจาก URL ไปยัง "beforeProcessing: function (data)" ได้อย่างไร -
ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชม