ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: hyh888 on January 27, 2022, 10:13:29 am
-
I hope to add new row automatically, when the DownArrow Key is pressed in the last row.
Following code works well when there is no filter used. But after filtering, pressing DownArrow Key couldn't add new row automatically when the cell in last row is selected. Would you like to provide help kindly?
beforeCellKeyDown: function( event, ui ) {
if(event.key=="Delete" ){
var nodes = [];
var type = this.Selection().address()[0].type
if(type == 'row'){
var Sel = this.Selection().eachRow(function(rowData){
nodes.push(rowData);
})
this.deleteNodes(nodes);
return false; //to prevent default behaviour.
}
}
if(!this.isValid( { rowData: ui.rowData } ).valid)
{return;}
if(event.key=="ArrowDown" && ui.rowIndx==this.getTotalRows()-1){
var rowIndx = this.addRow({ rowData: defaultRowData(), checkEditable: true });
// this.goToPage({ rowIndx: rowIndx });
debugger;
this.editFirstCellInRow({ rowIndx: rowIndx });
}
},
-
I guess you have been using filterModel: { hideRows: true } in which case ui.rowIndx==this.getTotalRows()-1 is not always true.
Please use this.getLastVisibleRIP() instead of this.getTotalRows()-1
-
Great help! It works.