实现JQGrid 4.3.0,Jquery 1.6.2和JQuery UI 1.8.16我遇到了内联编辑的问题。当内嵌编辑被激活时,一些元素被分配一个自动完成。当内联编辑被取消或保存时,自动完成并不总是消失(通过双击选择文本然后点击删除,然后点击退出以退出行编辑)。在编辑模式下不再考虑该行时,将自动完成控件保留在编辑模式下。JQGrid和JQuery自动完成
也许你可以告诉我初始化是否存在问题,或者我是否知道事件发布后的“afterrestorefunc”,表明这些字段可以返回到它们的“原始”状态。原始状态在JQGrid行中显示为数据。
我试过的行关闭,一个.remove()和.empty()后去除DOM:
...
"afterrestorefunc": function(){
$('.ui-autocomplete-input').remove(); }
...
但导致其他的问题,比如jqGrid的是无法找到的小区时序列化数据或编辑行,并且需要刷新页面,而不仅仅是jqgrid,以便能够再次查看来自该行的数据。
function CreateCustomSearchElement(value, options, selectiontype) {
...
var el;
el = document.createElement("input");
...
$(el).autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Services/AutoCompleteService.asmx/GetAutoCompleteResponse") %>',
data: "{ 'prefixText': '" + request.term + "', 'contextKey': '" + options.name + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: Trim(item),
value: Trim(item),
searchVal: Trim(item)
}
}))
}
});
},
select: function (e, item) {
//Select is on the event of selection where the value and label have already been determined.
},
minLength: 1,
change: function (event, ui) {
//if the active element was not the search button
//...
}
}).keyup(function (e) {
if (e.keyCode == 8 || e.keyCode == 46) {
//If the user hits backspace or delete, check the value of the textbox before setting the searchValue
//...
}
}).keydown(function (e) {
//if keycode is enter key and there is a value, you need to validate the data through select or change(onblur)
if (e.keyCode == '13' && ($(el).val())) {
return false;
}
if (e.keyCode == '220') { return false }
});
}
其它来源:该元素
自动完成功能是在该行的双击创建 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing
http://api.jqueryui.com/autocomplete/
更新: 我试着只创建元素聚焦时的自动完成,以及onblur时将其移除。这也没有解决这个问题。它似乎只需要触发自动完成下拉菜单。