ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: hyh888 on November 19, 2021, 04:56:07 pm
-
When I select a row in treegrid and press DELETE ,all data in grid are deleted.
When I select a row in grid and press DELETE in common grid, the data in the row(s) are deleted, but the empty row is still there. Is it possible to delete whole row (or rows)?
-
whole row(s) can be deleted by using deleteNodes or deleteRow API method.
https://paramquery.com/pro/api#method-deleteNodes
https://paramquery.com/pro/api#method-deleteRow
Example: https://paramquery.com/pro/demos -> context row -> Delete Row.
-
Than you for the help. But I hope pqgrid can fix two problems that I have described . They really make trouble.
-
Sure thanks for pointing out the issue in treegrid, it would be fixed in upcoming version.
As far as pressing delete key in grid is concerned it's the default behaviour of delete key to clear data in row which can be customized with help of beforeCellKeyDown event.
https://paramquery.com/pro/api#event-beforeCellKeyDown
-
Maybe this is the best solution now.
When I put some code in beforeCellKeyDown event, it is a little troublesome to get rowIndx list of the rows selected.
Only the last row (in selected rows) can be deleted easily. Is there any easy way to delete all selected rows?
if(event.key=="Delete" ){debugger;
//var Sel = this.Selection().getSelection();//There need be a For Cyclic Sentence to remove the repeated rowindexs.
this.deleteRow({ rowIndx:ui.rowIdx } );
}
-
eachRow method can be used to get unique rows in the Selection.
var nodes = [];
var Sel = this.Selection().eachRow(function(rowData){
nodes.push(rowData);
})
this.deleteNodes(nodes);
return false; //to prevent default behaviour.
https://paramquery.com/pro/api#method-Range
https://paramquery.com/pro/api#method-deleteNodes
-
Thank you, it works.
-
I found a new problem, when I seclected a cell and press delete key( after adding your code in grid), the whole row is deleted. I hope that only when the whole row is selected and del-key is pressed then to delete the whole row. Would you like kindly to show me how to fix it?
-
type of selection can be detected with help of API
var type = grid.Selection().address()[0].type
if(type == 'row'){
}
-
Great! It works. Many thanks for your kindly help.