list_treeview

Displays the contents of a specified list in treeview format.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X        

Syntax

expr list_treeview(list-name,row,col,height,width)
list               list-name
int                row,col,height,width

Description

list-name specifies the list.

row specifies the row position of the view box. -1 places the upper left of the box at the cursor position. -2 places the box in the center of the screen.

col specifies the column location of the view box. -1 places the upper left of the box at the cursor position. -2 places the box in the center of the screen.

height specifies the height for the displayed window in cells.

width specifies the width for the displayed window in cells.

Notes

The list-name is a two-column list. The first column is the description and the second column is either the value to be returned for that leaf node or another two-column list. list_treeview returns NULL if either Cancel, Close Window, or OK without a selection is chosen. Otherwise it returns the integer value that is stored in that leaf node's second column.

Example

{
int  i,rc;
list LL,L2;

LL = list_open("20 6",0,"A brand new title","Line one","Second line");
L2 = list_open("20 6",0);

list_mod(L2,1,"One","1");
list_mod(L2,1,"Two",2);
list_mod(L2,1,"Three","3");

list_mod(LL,1,"Level",L2);
list_mod(LL,1,"Leaf","99");

while (true) {
  rc = list_treeview(LL,-2,-2,8,20);
  if (rc == NULL) break;
  prompt(rc);
  }
}
Load a list with departments and the employees who work in each department.
{
int  i,rc;
list LL,L2;

LL = list_open("select deptname,deptnumb from org order by 1",999);

for (i=list_rows(LL);i;i--) {
  L2 = list_open("select name,id from staff "
                 "where dept = &/list_curr(LL,1)/ order by 1", 999);
  list_modcol(LL,1,L2);
  list_next(LL);
  }

prompt(list_treeview(LL,-2,-2,10,40));
}