jstree: Disable Multiple selection on root node only - jstree

How do you disable Multiple selection in jsTree only in root level?
Adding the code multiple: true, will disable multiple selection for my entire tree. But what I need is that it be disabled only in the root level.

Use get_node(data.selected[0]), to assign only one node.

Related

Changing node icon to "folder" when adding child in fancyTree

It seems to me that the standard behaviour in fancyTree, when adding child nodes is NOT to change the parent node to have a folder icon.
For example, see http://wwwendt.de/tech/fancytree/demo/index.html#sample-multi-ext.html and try adding a child node.
How is it possible to dynamically change the icon of the parent to a "folder" when adding a child?
I thought that I could apply renderTitle() to the parent node, but this did not do anything.
This question Dynamically change icon in fancy tree is similar, but (a) I could not get it to work, and also (b) I wanted a solution that didn't involve having to create new icons.
Folders may be empty, so this status is defined by node.folder = true (not by the fact that children are present or not).
So you could set node.folder and call node.render().
Note that setting an additional class may give the same effect, but may get lost when the tree is updated.
In jquery.fancytree.edit.js I added the following line
newNode.parent.addClass("fancytree-ico-ef");
The code snippet is as follows:
newNode.makeVisible(/*{noAnimation: true}*/).done(function(){
$(newNode[tree.statusClassPropName]).addClass("fancytree-edit-new");
self.tree.ext.edit.relatedNode = self;
newNode.parent.addClass("fancytree-ico-ef");
newNode.editStart();
});

How to expand a single sap.m.Tree item multiple levels?

How to programmatically expand the only single node in sap.m.Tree control? JSONModel.
In example
http://embed.plnkr.co/jb9tggpFhv4DHg69785v/
Here I want to expand only node 1.2.1 without expanding all unneeded nodes.
in your sample add this line :
oTree.onItemExpanderPressed(oTree.getItems()[1], true)
after the oTree.place
This will expand the second item
To expand one or more tree nodes programmatically, try the API sap.m.Tree#expand:
var selectItemIndex = oTree.indexOfItem(mySelectedItem);
oTree.expand(selectItemIndex);
Sample: https://sdk.openui5.org/entity/sap.m.Tree/sample/sap.m.sample.TreeExpandMulti

Refresh marker clusters after GeoJSON layer has changed

I am setting up a GeoJSON layer and on top of it a MarkerCluster layer
this.itemLayer = L.geoJson(items, layerOptions)
this.clusterLayer = L.markerClusterGroup()
this.clusterLayer.addLayer(this.itemLayer)
this.clusterLayer.addTo(this.map)
Upon update I am doing:
this.itemLayer.clearLayers()
this.itemLayer.addData(newItems)
this.clusterLayer.refreshClusters(this.itemLayer)
But the clusters do not appear, nor do the items in the itemLayer
Solution
this.itemLayer.clearLayers()
this.itemLayer.addData(this.props.items)
this.clusterLayer.clearLayers()
this.clusterLayer.addLayer(this.itemLayer)
Leaflet.markercluster does not keep track of Layer Groups (like your this.itemLayer GeoJSON layer group) unfortunately. When passed a group to clusterLayer.addLayer(), MCG will extract all individual (i.e. non-group) layers from that group, and forget any reference to the group.
See also Leaflet.markercluster issue #647.
Therefore when clearing your group with this.itemLayer.clearLayers(), it effectively removes all children from this.itemLayer, but this.clusterLayer is unaffected.
Similarly when adding data to this.itemLayer, that group creates new child layers, but MCG is unaffected.
Then when calling this.clusterLayer.refreshClusters(this.itemLayer), none of the child layers of this.itemLayer are part of this.clusterLayer, so it ends up with unexpected effect (maybe just doing nothing special).
If you want to change the clustered layers, make sure to remove them from MCG (e.g. simply do this.clusterLayer.clearLayers()), then add back the new layers into it. You could also remove the current MCG and build a new one.

Multiple Selection QTreeWidget

Does anyone know if its possible to select multiple items on a QTreeWidget and how to go about enabling the multiple selection?
All the items I want to be selectable are top level QTreeWidgetItems and all their children are set to be disabled (i.e QTreeWidgetItem.setDisabled(True) )
It is, you'll want to call setSelectionMode during init to enable QAbstractItemView::MultiSelection. QTreeView/QTreeWidget inherit QAbstractItemView, so it is available.
Then to disable the items, just hook on to QTreeWidgets.itemSelectionChanged() signal.
I think below will help:
youQTreeWidget.setSelectionMode(QGui.QAbstractView.MultiSelection)

Two ICEfaces panel positioned interacting

How do you constrain the elements of a PanelPositioned so they can only be dragged within the current panel? I have two vertical lists of different data types, one above the other. Both use a PanelPositioned to allow drag & drop reordering, but the elements can be dragged up and down to the other panel, generating an error
<ice:panelPositioned id="dragPanel1" var="dataType1var"
value="#{displayBean.dataType1List}" constraint="vertical">
<ice:panelGroup style="cursor:move;">
</ice:panelGroup>
</ice:panelPositioned>
<ice:panelPositioned id="dragPanel2" var="dataType2var"
value="#{displayBean.dataType2List}" constraint="vertical">
<ice:panelGroup style="cursor:move;">
</ice:panelGroup>
</ice:panelPositioned>
For icefaces 3.0, add a beforeChangeListener to the ice:panelPositioned element. This listener should then call event.cancel() if the event.getType() != to PanelPositionedEvent.TYPE_MOVE and the event.getIndex() and event.getOldIndex() are both greater than 1. If it is a move, then it is within panel. add/delete are moving between panels.
For icefaces 1.8.2 (neve used 2.0), you would need to add a listener to the ice:panelPositioned element. There is no beforeChangeListener. you will need a before list and current list (two copies). Both initialize to same elements when initializing backing bean. The listener, if a move - set before list to current list otherwise set current list to before list. Must be a copy, not a reference.