Forum


22:07

15/10/2012

When implementing JQGrid 4.3.0, Jquery 1.6.2, and JQuery UI 1.8.16 Ive come across an issue with the Inline edit. When the inline edit is activated, some of the elements get assigned an auto complete. When the inline edit is canceld or saved, the auto complete does not always go away. Leaving the auto complete controls in edit mode when the row is no longer considered in edit mode.
I've tried removing the DOM after close, .remove() and .empty():
...
"afterrestorefunc": funciton(){
$('.ui-autocomplete-input').remove();
}...
but that causes other issues, such as the jqgrid is not able to find the cell when serializing the row for data or edit, and requires a refresh of the page, not just jqgrid, to be able to once again see the data from that row.
Auto complete functionality for the element is created on the double click of the row:
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 }
});
}
...
Other Sources:
http://www.trirand.com/jqgridw.....ne_editing
http://api.jqueryui.com/autocomplete/
16:08

15/10/2012

Still having issues. This doesnt work in either browser. It doesnt seem to matter what type of text is in there. Sometimes it doesnt occur, but more so it does than not.
Once in inline edit mode double click a textbox-input and press delete. Then hit escape to cancel the edit. This is how i recreate the issue of the textbox's not going away.
Shameless Bump.
Also just tried editing the javascript so on focus or blur it creates or destroy's(unautocomplete) the auto complete.
That did not resolve it either.
It happens on firefox/IE8+
20:14

24/02/2009

Hi justinkneff,
If you are using jquery ui autocomplete with cell edit in jqgrid - you can do this as follows
afterEditCell:function(rowid,cellname,value,iRow,iCol)
{
if(cellname=='column_name')
{
jQuery("#"+iRow+"_column_name").autocomplete({source:<source>,delay:500});
}
}
If you are using inline edit - call this onedit
Hope this helps.
Thanks,
kris
16:25

15/10/2012

Hi Kris,
I tried to add the delay to my jqgrid auto complete generation but it doesnt seem to have resolved anything.
As of right now i generate the auto complete and it does pull data. I'll explain how i generate the jqgrid and that may help.
I use a remote json source. When generating the grid it sets up ondblClickRow as "tableRowDoubleClick," This generates the mode from the the previous function where the row is structured with the following:
item.edittype = JQGrid_EditType.custom
Dim edOpt As New JQGridEditOptionsCustom()
edOpt.custom_element = "CustomSearchElementSingle"
edOpt.custom_value = "CustomSearchSingleValue"
item.editoptions = edOpt
function CustomSearchElementSingle(value, options) {
return CreateCustomSearchElement(value, options, 'Single');
}
This is the call to the top statement where it generates the "custom element" for it to be an "auto complete" textbox.
var c1 = document.createElement("td")
... custom search code fom previous post...
c1.appendChild(el);
19:59

15/10/2012

I posted on stack overflow as well:
I have a custom enable/disable function before the calling of the auto complete. This causes multiple reference calls to the same jqgrid cell causing conflict. So during my double click event on the row where it's supposed to open up inline-editing. The row is taken and analyzed for what cells need to be enabled/disabled based on the record type it is. It determines the fields that are available by an associative array, serialized into a hidden field value, from the code behind during page load.
function tableRowDoubleClick(id, iRow, iCol, e) {
...
setCellEditabilityByRecordType(id);
...
}
The Cell editability is set by the following way:
function setCellEditabilityByRecordType(id) {
//change some of the fields to read-only
var grid = $('#mygrid');
var i;
var cm;
var cellRecordType = grid.jqGrid('getCell', id, 'RecordType')
//Determine Fields Disabled by evaluation of data from a hidden field.
var disablefields = eval(pg_FieldDisable[cellRecordType]);
for (i = 0; i < disablefields.length; i++) {
cm = grid.jqGrid('getColProp', disablefields[i]);
cm.editable = false;
}
...
}
...
So when the initial setup of the row reacts to being double clicked, the cell editability is set. Then the "CreateCustomSearchElement" triggers.
However if the user double clicks on the row, it triggers the double click again, setting the cell editability, but for the same row. So this causes multiple references to the cell that, at this point, I'm not sure what's happening. All I know is I have to centralize the row editability to one function or find a way to read if the current row that was double clicked really needs the editability set again.
References JavaScript Assocaitive Arrays
Most Users Ever Online: 715
Currently Online:
36 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66