let me guess, opening the nodes and clients.eval is in same command?
chillworld ( 2015-07-09 13:53:17 +0800 )editif not, can you create a small fiddle where you reproduce this problem?
chillworld ( 2015-07-09 14:02:44 +0800 )editFirst time here? Check out the FAQ!
I have a huge tree and a textbox to search in the tree, when i type a word in the search field, i have a javascript script which iterate on each nodes of the tree to find nodes which are equals at the search field. My problem is that the script don't iterate on all the tree, it's just iterate on the fifty first nodes because ZK don't generate all the nodes in the DOM.
Zk generate after first fifty nodes this HTML for each node,
<span class="z-tree-line z-tree-spacer"> </span><span class="z-tree-line z-tree-spacer"> </span>
so javascript can't process these nodes.
I use DefaultTreeModel as tree model.
<tree id="treeview" class="arbre-contrat" model="@bind(vm.contratTreeModel)" selectedItem="@bind(vm.selectedContratTreeNode)">
<template name="model" var="node">
<treeitem open="@bind(node.open)" id="${node.data.hierarchyId}">
<treerow sclass="${node.data.dataType.cssClass}" >
<treecell onClick="@command('openNode',node=node)" >
<label value="${node.data.label}"/>
</treecell>
</treerow>
</treeitem>
</template>
</tree>
Anyone have a solution to iterate all the tree ?
yes,I open my nodes and call js in the same command
@Command("openSearchTextNode")
public void openSearchTextNode() {
if (StringUtils.isNotEmpty(searchText)) {
//root node
TreeNode<OctaveTreeRow> contratNode = contratTreeModel.getRoot().getChildAt(0);
//open node if the node contains the value
searchTextInChild(contratNode, searchText);
//like BindUtils.postNotifyChange(null, null, this, "contratTreeModel");
notifyChange("contratTreeModel");
// js call
Clients.evalJavaScript("updateSearchDisplay(true);");
}
}
I will explain more my situation, i have already an algorithm which open nodes if the node contains the value of the searched text. After that i call my javascript function to hightlight with
Clients.evalJavaScript("window.setTimeout('updateSearchDisplay(true)',100);");
But after, all my nodes that are equals to my searched text are not highlighted, because in the dom some nodes have this value:
<span class="z-tree-line z-tree-spacer"> </span><span class="z-tree-line z-tree-spacer"> </span>
let me guess, opening the nodes and clients.eval is in same command?
chillworld ( 2015-07-09 13:53:17 +0800 )editif not, can you create a small fiddle where you reproduce this problem?
chillworld ( 2015-07-09 14:02:44 +0800 )editThe issue with doing the search on the Viewmodel side is that actualy my search Js script changes the node dom to add tag around the searched text.
Don't really see how would i do it if the search is done back side, i cannot pass html in my node ?
The opening of the nodes is for rendering them. You can always trigger your script later(and close the nodes). To do this you have to echo an event so that the Gui can render first your opened items before we call the javascript. Afterwards we can do Clients.evalJavaScript("mineFunction()");
Hey Roma,
The only solution like you suggest it, is opening the whole tree and close it afterwards.
But I like to point out, this will not be good.
Your performance will decrease a lot, because it's a huge tree.
I think your problem is how you do the search.
Most treemodels implement the TreeOpenableModel, so why don't you search in the viewmodel and eventually open just those nodes?
ZK will render them at that point, without rendering all your items.
If your script highlights the text, you can always run after the command the script.
Hope you can figure it out now.
While I did try to make you clear to try separate the javascript and the rendering.
So try this :
@Command("openSearchTextNode")
public void openSearchTextNode(@ContextParam(ContextType.BINDER) Binder binder) {
if (StringUtils.isNotEmpty(searchText)) {
//root node
TreeNode<OctaveTreeRow> contratNode = contratTreeModel.getRoot().getChildAt(0);
//open node if the node contains the value
searchTextInChild(contratNode, searchText);
//like BindUtils.postNotifyChange(null, null, this, "contratTreeModel");
notifyChange("contratTreeModel");
binder.postCommand("callJavaScript", null);
}
}
@Command
public void callJavaScript() {
// js call
Clients.evalJavaScript("updateSearchDisplay(true);");
}
Greetz chill.
Asked: 2015-07-09 10:23:54 +0800
Seen: 41 times
Last updated: Jul 10 '15
ZK 7.0.3 doAfterCompose is not called for GenericForwardComposer
Power of ZK Calender With Charts 2 and Other Components
ZK7 atlantic theme: vlayout/hlayout spacing
Structuring zul-code without includes?
css zk 7.0.3 with ie9 not work
Change listbox MVVM template with Java or how to let user change column order