In ExtJS 4, How do you delete a tree node when the associated grid information to the node is deleted at random - extjs

My code so far populates via drag and drop tree nodes and leaves from a grid panel. I want to know how to remove a tree node when the grid information associated with it is removed.

You should have something like id property in your model both in grid and tree. So when you remove record in the grid you then search for the node with this id in tree and remove it as well. Another way is just save the reference to the node when you drop it.
The flow is:
user drags and drops record from grid to the tree
when the record is dropped and new node is created you save reference in the grid's record
onNodeDrop: function(){
grid.getSelected().treeNode = tree.lastCreatedNode;
}
then when you delete record in grid you could delete node as well.
Note - this is just a psuedocode, is won't work. Just to give you an idea.

Related

How to drag and drop the nodes from left tree to right tree as a copy not move

Hi i am using Angular 14 Version
I am Working on Prime Ng Drag and drop control, here i am facing some problems like, when i drag the node from left tree and drop it to the right tree that time dragged node is removing from the left tree.
How to prevent or retain the node even i am after doing drag and drop between the trees. Trying to drag our own items like, https://primefaces.org/primeng/tree/dragdrop
How can i do this? Help me.
do you mean this? https://www.primefaces.org/primeng/dragdrop, im not sure if i understand what you ask.
If you want items to keep their position after you refresh the page you will need some DB to remember their status,
however if you want dragged item to stay in the left tree after dragging you will need to change source code a little bit
drop(event) {
if (this.draggedProduct) {
let draggedProductIndex = this.findIndex(this.draggedProduct);
this.selectedProducts = [...this.selectedProducts, this.draggedProduct];
// this.availableProducts = this.availableProducts.filter((val,i) => i!=draggedProductIndex);
this.draggedProduct = null;
}
}
try to comment the filter line to prevent item to be deleted from left tree

How to show a selected record in the visible portion of a tree

I have a tree control in a fieldset. Am able to populate the tree fine.
I'm using this command to programmatically select a specific node in the tree:
Ext.getCmp('projectsTree').getSelectable().setSelectedRecord(<node>)
where node is the node I want to select. This command works fine. What's happening is that while the record is selected, it is not in the visible portion of the tree. It can be below the visible portion of the tree and I would have to scroll down to see that it is selected. Does anyone have any tips on how to both select the record and have it show up in the visible portion of the tree.
I've seen recommendations using focusRow or selectPath, but I haven't been able to get that working.

kendo tree view move programmatically item to another node

I use kendo tree view with angular. I try to move items between nodes programmatically, actually to change the item's parent, without drag and drop, but with the same result.

how re-expand tree grid node if it is expanded?

On my treegrid when I expanded tree node if there is not data available(and if I added data into database later) I can't expand this node again. need to refresh page. how can I set it expandable? or how force treegrid node to send request again on expand?
If I understand your question, all you have to do is update node (expanded) data. This can be done as follows:
this.getStore('MyTreeStore').load({ node: someNode});

Treepanel losing selection after appending nodes. (ExtJS / Rally)

I am creating a treepanel object in Ext JS which dynamically adds nodes to the tree based on child information returned from the server. The problem I'm having is that I would like to be able to select multiple objects from the tree and have that selection remain after expanding a node. Since appending nodes is effectively changing the tree, the selection is lost. Is there any way I can preserve this selection after appending the new nodes?
you could save the nodes or ids of the nodes being selected and then reselect them after appending additional nods.

Resources