Some tips about creating "Tree view" in List pages





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.

 

And last:

  • 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

 

Gedas Busniauskas
Microsoft Lithuania
Microsoft Customer Service and Support (CSS) EMEA

Comments (8)

  1. BlackTiger says:

    Here is one more issue – it resets any applied filters and not compatible with "Save as view" functionality.

  2. John says:

    Great instructions. Much easier then doing it in a form.

    I am having an issue when I refresh a treeview in a listpart it loses the "child" records and the "+ -" is missing. I am using a tempRec as the source. The tempRec is being populated on the OnAfterGetRecord() of the master record.

    How do you re-populate records when a refresh(F5) is called?

  3. Gedas says:

    Referesh reloads recorset and redisplay page.

    It is hard to say how it works with temprec and treeview.

    Treeview is "young" technology, also we had few issues in combination TempRec with RTC (fixed in few latest releases), so here might be error too.

    If you can reproduce issue, then please call our support team, maybe we'll have fix for it.

  4. iPeon aka André says:

    Thanks for this great blog entry.

    It helps to find an entrypoint for this technology in pages and it is much easier as to learn from a standard page like "Order Planning" Page 5522.

  5. RV_Kolkata says:

    Getting this error "You have specified an Unknown Variable: Indentaion" while giving the IndentationColumnName as "Indentation" in the Group property.

  6. Peter says:

    Another issue:

    Normally F8 copies the Field value of the upper line to the current line.

    This works fine. There is one exception: if the field is set as one of the Indentation Controls in the Group Repeater, F8 has no effect.

  7. Praveen says:

    Hello experts any idea how to Expand or Collapse the entire tree or a specific tree node using code?

  8. Gokulnath says:

    while using OnAfterGetRecord() trigger in page it runs for two times once a record is selected, Why??
    can any one help..

Skip to main content