treepanels drag and drop default behavior - extjs

I have two treepanels which I want to drag and drop between. I understand there is a plugin for this, however I want it to behave a certain way.
In my treepanels, I am showing the root node of the tree, and then all its children. The default DD allows the user to drop items at different levels on the tree(i.e. sibling of root, child of root) where I want all items to be a child of root for consistency. How can I make it so that any drag into the treepanel associates the item as a child of the root and not a sibling of the root.
Why:
For a user who doesn't understand how this functionality works, one millimeter in either direction can change the item from being a sibling to child or vice versa.
Also, I would like it so I can only drag away those children and the root can't be moved, if at all possible.

Yes it is possible. You can listen to the 'beforedrop' event on the target Tree panel's tree view and achieve what you want. Something like this
http://jsfiddle.net/EYtnk/1/ ..
One of the arguments of the beforedrop event is the node being dragged. You can check if it is a root node of source tree and just 'return false;'
P.S: In the example, i just used the same store for both the trees.. so the nodes get added on either side.

Related

ADF tree binding issue

I'm using 3 levels tree VO's. All three VO's has bind variables. The VO's are connected via View link. I'm using createViewLinkAccessorRS in order to pass the variables from parent to child VO.. i defined Target Data Source (EL_expression) for second and third level.The tree works fine, and the nodes filled correctly (all the way down). The Problem is that the second and the third tree level attributes are only shown in the tree component. anywhere else in the page it looks like they are empty ({bindings.(attname).inputValue} = null) (E.g - after dragging the third tree level "FlowOrder" from the AppModuleDataControl and create a form out of it, and selecting the second node of the tree will update all the third level tree node (please see attached image), but will leave the entire form which was just created empty)
Any idea why the FlowOrder bindings are empty? i assume that maybe it has to do with the bind variable of the VO .. i even thought i would change the tree selection listener so on the second level click it will perform a full query of "FlowOrder" via executewithparams, but it does not make any sense because the data was fetched already after clicking level 2 tree)
(Jdeveloper : 12.2.1.2.0)
attached image: Details
Check out my explanation on trees and example application in another post: ADF filter table based on tree selection The tree shows data from view link accessors. The form shows data from view instance. They are in different state.

How can I implement a columns UI using React?

I'm talking about the UI as seen in this screenshot. In that program, macOS Finder, you have a column on the left, which lists all the items inside a directory. If you click an item, and that item is itself a directory, a new column opens on the right containing all its entries, and this repeats forever.
I'd like to write a UI like this using React for a simple text-editing web application. Each column would contain folders or text 'files'. Clicking a folder would open that folder's children in the next column over; clicking a text 'file' would place its text in a textarea element for reading or editing.
But I can't figure out how to structure the data.
I think I'd want a sort of tree, where nodes can be either text-files or folders/trees themselves. But how would I then render that tree in React, what pattern of components could I use? Would I render the top level of the current tree into one column component, and have an onclick handler in that component that adds a new column to the parent if a subfolder gets clicked? And if so, would I pass that component some reference to a sub-part of the tree, or pass over the entire portion of that tree?
You can use the material UI Menu component. It lets you have subMenus as well
http://www.material-ui.com/#/components/menu

Disabling selection of a node in ExtJS tree panel if the node is not a leaf node

I am using ExtJs 4.1 TreePanel control & want to disable selection of a node if that node is not a leaf node. Do we have any property out of the box to achieve this?
So If the node is not a leaf node, disable selection and if user click on that node, system should not fire any event (itemClick or select etc).
Thank you
There's no property, but you could always key on the beforeitemclick or beforeselect event (or both, depending on what you need to do). Add a handler for this event, check if the clicked node is a leaf, and if it's not, simply return false. That will halt the default behavior and effectively disable the non-leaf nodes.
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.tree.Panel-event-beforeselect

How to collapse tree node with no children

Using ExtJs 4.2.
I have a tree panel where all nodes have arrow for expanding. On expanding a node with children, the arrow for collapsing remains. However, on expanding a node without children, the arrow of the node disappears. So there is no collapsing possible on that node.
How to keep the arrow and collapsing functionality on a node without children?
See the screenshot: both nodes (on the same level, black) are expanded, however only the node with children has a arrow for collapsing again.
AFAIK double-clicking the node toggles expand/collapse. I've tested it in 4.0.0.
Edit:
It has probably changed in Ext4.2 though. The empty folder node seems to be always open (with no children inside). I guess the reason might be to clearly indicate it's empty node to the user (without even interacting with it).
So far we are solving this problem by checking for children on an expand event. If there are no children, we collapse the node again without the user taking note.

Checkbox behavior in RadTreeView control

I am using a Telerik RadTreeView control to build a tree with nodes containing checkboxes.
The default behavior for this control is that if you check a parent node, all of the child nodes within it will also become checked. Is there any way to change this behavior? I want to be able to check a parent node on or off and not have it affect the children.
Thanks
I would try doing some magic when the PreviewChecked event happens. I'm not sure, but maybe you can use it to detect a checkbox is about to become checked, and prevent this from happening if it is not the checkbox the user actually clicked in.
You could also do some stuff in javascript like this
function checkNode()
{
var selectedNode = treeView.get_selectedNode();
if (!selectedNode)
{
alert("You need to select a node first.");
return false;
}
selectedNode.set_checked(!selectedNode.get_checked());
return false;
}
This is straight from telerik but simply loop through all the children nodes and turn them back off (or back on when you click it off). The problem is if you want to maintain the state of the children nodes regardless of the parent. Then you need to hold that info in some variable.
The other option is if you don;t want the children to even have checkboxes, then simply don;t make those nodes "Checkable" in the server side code. (I'm sure there is a way in the client side too)

Resources