问题
I'm trying to use jQuery UI Autocomplete inside a jqGrid in the dataInit
. I'm doing it like this:
{ name:'ac_fin_g', index:'ac_fin_g', width:75, editable: true, edittype: 'text',
editoptions: {
dataInit: function (elem) {
$(elem).autocomplete({
source: 'autocomplete.php',
select: function (event, ui) {
#('ac_fin_g').val(ui.item.value);
}
});
}
}}
And in the function ondblClickRow
I'm passing select
like a parameter:
ondblClickRow: function (id, select) {
if (id) {
if (id !== lastSel) {
$('#list').restoreRow (lastSel);
$('#list').editRow (id, true, select);
lastSel = id;
} else {
$('#list').restoreRow (lastSel);
lastSel = "";
}
}
}
This is working but just for the first row.
回答1:
I think that the main reason of your problem is wrong usage of ondblClickRow
callback. The second parameter of ondblClickRow
callback is the index of the row in the grid. There are other option which you can use. The most full prototype of ondblClickRow
callback contains 4 parameters:
// one can use ondblClickRow: function (id) { below because iRow, iCol, e are not used
ondblClickRow: function (id, iRow, iCol, e) {
var $self = $(this);
if (id !== lastSel) {
$self.jqGrid("restoreRow", lastSel);
lastSel = id;
}
$self.jqGrid("editRow", id, true);
}
The third parameter of editRow is oneditfunc
callback. The usage of iRow
number as oneditfunc
callback is wrong.
来源:https://stackoverflow.com/questions/15433876/autocomplete-datainit