I am constructing an asp.net tree view by querying sharepoint user profiles.
The accountname that is to be selected and the root node accountname is being read from query string.
I also need to have configurable exapanddepth for the tree.
How do i select the node if the node belongs to the 4th level and say the expanddepth is less than 4 (1,2, or 3).
Setting relevant node in the 4 th level as selected and setting the ExpandDepth property of the treeview does not look to help.
So essentially, i need to keep the tree expanded untill the selected node(only that navigation that leads to the selected node) but keep other part of the tree expanded only till as defined by expanddepth.
Thanks
I got it working. Its pretty simple.
From the tree node, get the selected node value path.
The path will have values seperated as given in the path seperator.
Keep getting on the nodes that are part of the value path got above starting from rootnode.
For each node of the value path , just call the expand function.
Please note that if we dont do the loop and just expand the node with the full value path,
the treeview's ExpandDepth property will take prominence and therefore the visiblilty of the selected node actually depends on the ExpandDepth in the present scenario.
Regards
Related
I have an array where each item has fields (Name, ItemID, ParentID, Level).
Level is how deep into the tree the node is placed. Root level items have Level = 0 and ParentID = NULL.
How do I keep track of the parents and build this tree?
Current (incomplete) Algorithm looks like:
For items in record set:
If current item level = 0, it is a root node.
Else if current item level is greater than previous item level, AddNode a child to previous item.
Else if current item level is equal to previous item level, AddNode as a sibling to previous item.
Else if current item level is lower than previous item level, I need to go back up a level and insert a node (how?).
The array is sorted in a way that we can be sure whether the next item is an immediate child or sibling based on the 'Level'. The items in record set are represented as iterable objects in an array of arrays.
Thank you for your help to determine the correct algorithm and approach to solve this.
Solution:
Keep track of parents in an array, and remove them as needed when you know they won't be a parent ever again. The record set is ordered on the database level to ensure that every child of a particular parent is directly consecutive in the list. This affords me some ease of programming logic.
This seems like an unusual circumstance, alas, my code below creates the desired result.
I want to have something similar to the example here http://demos.telerik.com/kendo-ui/treeview/filter-treeview-in-dialog but with some changes which are
Server side filtering
remote datasource
Load on demand true (when no search)
For example, the expected behaviour is initially the tree will be loaded from remote datasource with load on demand (only first level will be retrieved) and when user enter a search text, the search will be performed on server side and all results will be returned and no lazy loading. last thing when user clear search text, the tree will return to lazy loading again and load on demand would be true.
And here are more details about my case
Tree Structure will be only two levels, let say type and item
root level is fixed, all roots will always shown
first json object structure which will be used in all data retrieval will be
Id
Description
HasChild
Childs
so data will be retrieved from the server as following
first load will be the root level only, has child will be true for all roots, and children will be null
when expand node (with lazy loading), only return the children for the expanded node
when search (will not lazy loading), return all roots with matched children in children property
Any ideas?
as Ross Bush says, it is not a built in functionality, after a lot of tries and research, i found that the issue is two things:
I cannot change the load on demand after initialization (even i use setOptions function)
I cannot change the value of children after datasource intialized !!!
so, the solution (or acutally a workaround) is re-intialize the datasource and the tree when i change the mode from search to view and vise versa !!!. this is how i solved it
Thanks all for your contributing
Currently i'm trying to count the total of items that are selected with xpath.
to count all items i can do:
count(/process_data/formData/xdp/datasets/data/Data//#selected)
but how can i count all items where the value of selected is true. (not knowing the previous node). If i knew the previous node i could do:
count(/process_data/formData/xdp/datasets/data/Data//node[#selected=true]/#selected)
but since i don't know this data, i can't use this. any ideas?
If you mean by not knowing the previous node that you want to check all nodes that may have a selected attribute I think you just have to change your XPath expression to:
count(/process_data/formData/xdp/datasets/data/Data//*[#selected='true'])
This assumes that selected is actually a string attribute.
What is a good way to map a level of a treestore to a flat store. In my case,
I want to group criteria for a search. All search criteria are inserted into the top level of the treeStore, unless they are grouped, in which case they become children of a top level logical(AND or OR) node. So, within a grid, I want to display the top level nodes (via some toString method I will define in the model). This is the easy part, I just go through the top level of my tree and generate the output for the Store/grid. However, when I want to remove something from the grid/store, it also needs to be removed from the treestore which represents the actual logical structure.
So, How can I keep track of which textual store item corresponds to which top level node in my treeStore?
Load your data onto the store or treegrid (but not both), then collect the records from one object and just add them to the other (using store.add() or treestore.getRootNode().appendChild()). At this point if you have a reference to the record, you can just say store.remove([record]); and then treestore.getRootNode().removeChild(record); to remove it from both.
I have a TreeStore with objects that I view and manipulate through a GtkTreeView/GtkTreeModel setup.
I also have a TreeView showing a TreeModelSort of the TreeStore, which I use for sorting on columns like name and date.
The problem is, that the sort mechanism only sorts the root nodes, even if a underlying child node has e.g. a date that is later/sooner than the roo tnodes' dates.
So, the question is if there is any way to show the objects as a List, not a tree, but keeping the references to the paths in the other TreeView?
I would suggest a TreeModelFilter that filters out any rows that are child rows (ie, depth > 1). You can filter your sorted model, and display just the root nodes.