我一直在尝试将数组从全局变量(codata
)传递到editoptions
(jqGrid)的选项数组。我的代码表示如下:未通过jqGrid的editoptions参数的数组(json)
--------- countries_list.php引发以下JSON数组-----------
["ABU","AD","AE","AF" .... "ZA","ZM","ZW"]
----- ----使用jqGrid代码的PHP脚本----------
jQuery(document).ready(function(){
var codata = new Array();
$.getJSON('countries_list.php', function(list){
$.each(list, function(val) {
codata.push("'"+val+"'");
# --- Here alert() displays 'codata' with all the elements ---
});
});
$("#datatable").jqGrid({
......
// some code until colMode specs
......
{ name:'guco',
index:'guco',
edittype:'select',
width:90,
editable: true,
editoptions: {
formatter:'select',
value: codata # --- array is not passed, it comes empty ---
},
sortable: true,
resizable: false
},
.....
---------使用jqGrid代码的PHP脚本----------
任何提示如何得到这个固定?,thanx提前。
马里奥Benitez.-
异步操作可能会导致将数据存储在数组中的问题 – 2011-05-12 19:32:14
事实上,因为它是异步'codata'是未定义的,因此您引用它的时间并且是回调函数。 – Zlatev 2011-05-13 08:19:13