【发布时间】:2013-08-16 10:18:02
【问题描述】:
我的JsonResult如下
[{"name":"Group 1"},{"name":"Group 2"},{"name":"Group 3"}]
我在编写for循环时有点困惑,那么如何在jqGrid的editoptions中迭代这个或在buildSelect函数中获取name的值?我在 jqGrid 中的 colModel 代码如下
{ name: 'GroupName', index: 'GroupName', width: 60, align: 'center', search: false, editable: true, edittype: 'select',
editoptions: {
dataUrl: "/Category/GetCategoryGroup",
buildSelect: function (response) {
if (response && response.length) {
// for loop iteration to get name values
}
}
}
},
【问题讨论】:
-
你不知道如何遍历数组?
-
@FelixKling:我的问题不是如何遍历数组。我自己不知道如何在 buildSelect(jqGrid) 中使用这个内部函数并将其作为下拉列表返回?
-
参见:stackoverflow.com/a/4102155/218196,“更新”部分。
标签: javascript json jqgrid