我尝试使用自动填充进行表单编辑..每次用户打开编辑表单时,其来源都不同
打开编辑表单时:
beforeShowForm: function(frm) {
var id = grid.jqGrid('getGridParam','selrow');
if (id) {
var ret = grid.jqGrid('getRowData',id);
AccCode = ret.szAccCode;
};
$.post("url_getchildren", { szAccCode: AccCode}).
done(function(data) {
lschildcode=data;
});
},
我有来自服务器的管理结果, 但我不能把它发送到网格。
colModel
:
{name:'szAccParentCode',index:'szAccParentCode', editable:true, edittype:'text',
editoptions : {
dataInit: function(elem){
$(elem).focus(function(){
this.select();
}),
$(elem).autocomplete({
source:lschildcode
})
}
}
},
为什么我无法将lschildcode
传递给自动填充源?每当我在框中输入时,自动完成功能都会将术语发送到服务器。
TIA
答案 0 :(得分:0)
我认为在执行dataInit
autocomplete
之前,done
(以及$.post
)将被称为。
要解决此问题,您可以在$("#szAccParentCode").autocomplete({source:lschildcode})
内调用done
。
另一种方式:可以使用URL作为source
的值。 URL可以包含一些其他参数。如果您需要使用HTTP POST,可以将source
声明为函数,并在response
或success
实现的done
内调用source
参数(回调函数)。只需查看the remote with caching示例中source
的实现并检查代码(单击“查看源代码”)或检查$.ajax
用法附近的jQuery UI自动填充的源代码(请参阅{{ 3}})。