In Microsoft Dynamics NAV 2009 in new Role Tailored Client we have new feature – we can show lists in “tree view”. We can expand/collapse nodes and make lists more interesting and more visual.
However this new feature isn’t documented very well and every developer needs to collect his own experience. With this article I will try to make this way easierJ
So if we want to see Tree View we need to have:
1. Table with field type Integer. This field will get us major point – will show is record root or fork or leaf.
a. Few words about “IndentationColumnName” field; (that how property to indentation field is named on Pages)
i. Field could be only type Integer.
ii. Allowed values are >=0. I didn’t find upper limit, but because view indentation shift is calculated based on this value then with “big” values filed is indented too far to right that becomes invisible.
iii. Root record has “0” indentation. Higher numbers means higher indentation. There could be several “0” records placed on table.
2. Page type List.
a. On page designer there must be “Group” & subtype “Repeater” and we need to set on it:
i. Property “ShowAsTree” = Yes
ii. Property “IndentationColumnName” must be field name we defined in table as indentation field.
b. Repeater must include fields we want to see in list. First field in list will be indented and will have ‘+-‘ signs for collapse/expand list. Indentation field could be not included to page.
If everything is done (and you have data in the table), then run page. Fortunately for me I have table with some data in it:
Few interesting points I want to have your attention:
Field “Int” is used for primary key
Field “Indentation” has indentation value used for Tree View.
Both fields are not used on page so field “Txt” has text showing which record and what indentation level is.
There are no relations between primary key and indentation. You see 0 indentation is record 18.
So run page and see:
If we “Expand All” we’ll see:
Wow it works J
Please keep in mind:
There could be few records with the same indentation.
If after record ‘A’ is going record ‘B’ with bigger indentation then we can expand record ‘A’.
View belongs to sorting. I sorted records based on “Indentation” value. So I see “full tree” started from “0 level”. But really “0 level” record is 18 record by primary key, and if change sorting to primary key I will see different tree.
You see now: first record has primary key 0 and indentation level 5, but next record has level 1 so my first record has no possibilities “collapse/expand”. Record 18 with level 0 is in the end of list and only one record is after it, so “my root records from previous view” now can expand/collapse only one record.
You can’t insert manually new records to “Tree View”. Please use code if you want to create new records from “Tree view”
You can delete records manually from “Tree view” one by one. If you will try to delete not expanded record then only this record will be deleted.
You can edit records in “Tree view”. You can modify even “Indentation level” field, just after modify “Refresh” (F5) and you will see “new view”.
There were few stability issues in “Tree view ”, so please use possible latest NAV builds
If you have questions/issues regarding this functionality, please contact our best ever NAV support team J