ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: arbyter on May 09, 2019, 03:24:32 pm
-
hi
i am looking for a method to perfom nextEdit when the down-key is pressed. onSave: nextEdit works just in the same row.
Any hint?
Thank you
-
editorKeyDown event could be used, it would also require boundary checks.
editorKeyDown: function(evt, ui){
var grid = this;
if(evt.keyCode == 40){ //down key.
setTimeout(function(){
//debugger;
ui.rowIndx ++;
ui.rowIndxPage++;
grid.editCell(ui);
},10)
}
}
-
thank you, it works fine. But i have another question, i am stuck on it:
not all records are ediatable in the list, just the ones that belong to me. So i added a class editable to the pq_rowcls and
var colModel= [
... {title: "Vorname",dataType:"string",dataIndx: "vorname",editable:function (ui){return ui.rowData.pq_rowcls && ui.rowData.pq_rowcls.indexOf("editable")!=-1}},
{title: "Name",dataType:"string",dataIndx: "name",editable:function (ui){return ui.rowData.pq_rowcls && ui.rowData.pq_rowcls.indexOf("editable")!=-1}},
...
]
i altered your snipped so:
editorKeyDown: function(evt, ui){
var grid = this;
if(evt.keyCode == 40 || evt.keyCode == 38){ //down key.
setTimeout(function(){
//debugger;
evt.keyCode==40 ?ui.rowIndx ++:ui.rowIndx --;
evt.keyCode==40 ? ui.rowIndxPage++:ui.rowIndxPage--;
if(ui.$cell.parents('.editable'))grid.editCell(ui); <--------------------this does not work, it is not reaching the row
},10)
}
}
-
hi
i think, triggering a dblclick event could be the most elegant way to achieve my goal. (invoke editor just on admitted rows)
but no look.
my snippet:
if(evt.keyCode == 40 || evt.keyCode == 38){ //down key.
setTimeout(function(){
//debugger;
evt.keyCode==40 ?ui.rowIndx ++:ui.rowIndx --;
evt.keyCode==40 ? ui.rowIndxPage++:ui.rowIndxPage--;
ui.$cell.dblclick() //does not work, tried also .trigger('dblclick')
},10)
}
-
ui.$cell.dblclick() logic is incorrect since it's the same cell in which key is pressed down.
you could put increment/decrement logic in a do/while loop and use isEditable method to decide edit-ability of cell. break out of the loop when editable cell is found.
https://paramquery.com/pro/api#method-isEditable
and finally use editCell method to edit cell.
grid.editCell(ui)
-
if(grid.isEditable({rowIndx:ui.rowIndx,colIndx:ui.colIndx}))grid.editCell(ui)
did the trick
thank you