實現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時將其移除。這也沒有解決這個問題。它似乎只需要觸發自動完成下拉菜單。