Hi,
Basically I have a simple treeGrid where I need to delete a row (and its children). I want to do it programmatically, via external button.
Tree has a primaryKey on a field called "primaryId"
When executing this method on treeGrid:
this.treegrid.deleteRecord('
primaryId
', {
primaryId: 1234 });
it works, only if given id does not have children. If there is anything under this node, it fails to delete node (but it changes the focused row).
Question 2.
After node removal - I want to control which row is selected, how to do it. because when I do it like that:
this.treegrid.deleteRecord(' primaryId ', { primaryId: 1234 });
this.treegrid.selectRow(0);
It moves to top row just for a fraction of second and then it gets back to some random node.
Thank you.
Unfortunately I do not want to delete selected record, I want to delete a record, which not necessarily is selected (rarely it will be the selected record). So deleteRecord is not an option for me.
In your example, if you do:
Only one row is deleted, not all children ( although deleteRecord() deleted all children). I'm looking for a way to delete arbitrary record with children regardless of selection.
Also, when I call:
Top row is not selected, it blinks for a fraction of a second and then goes to other row
|
[app.component.ts]
click(){
this.treegrid.deleteRecord('taskID',this.treegrid.getCurrentViewRecords()[0]);
setTimeout(() => {
this.treegrid.selectRow(0);
},2);
}
|
Timeout is not an option, because:
- tree will select a different row for a fraction of a second. Selecting a different row for a fraction of a second triggers a backend action in my system and changes UI view for a user. I want to void this.
Any way to disable this auto focus change which comes with delete record?
About deletion itself - what is:
this.treegrid.getCurrentViewRecords()[0]
I want to delete row with children based on primaryKey, not by index.
|
[app.component.ts]
…. this.treegrid.deleteRecord('taskID',[{taskID:1},{taskID:2}]); |
Thanks.
I understand that I can delete many records, but traversing the tree just to get all children nodes (it can have multiple levels) is cumbersome. I might end up with a
deleteRecord with an array of 1k elements. Please raise an improvement request in the backlog - option to use deleteRecord with primaryKey which would delete node + all children.
On the second subject, you do not need a video, you can use your own stackblitz example.
Changes to make:
and in ejs-treegrid add
Reproduce steps 1:
- select node Design
- click delete parent button
- observe the console
It will write to console id 5 then id 0. This means that selecting row 5 was triggered. Selection of row with id 5 is not wanted. In my case selecting a row triggers backend call and UI changes.
Reproduce steps 2 (this one is not always visible, but give it a try few times;
- select node 'Plan timeline'
- click delete parent button
- observe the console
Sometime you will see:
0 and 1 being triggered
and sometimes
1 and then 0 being triggered.