auto_stories Bilgi Bankası chevron_right Form chevron_right Makale

Tree Listv5

Used to report data hierarchically. The requested information is displayed as a tree list.

Appearance in ToolboxAppearance in Free FormAppearance in Responsive Form
          

 

 

Compatibility

Free FormResponsive FormMobile
Resim 58, ResimResim 57, ResimResim 56, Resim

 

Properties

  • Name: The name of the tool is written here.
  • Text Size: Sets the size of the text inside the tool.
  • Height / Width: Sets the height and width of the tool (the width field has been removed from Responsive Forms).
  • From Left / Top: Sets the distance of the tool from the left and top (this field has been removed from Responsive Forms).
  • SQL Query: SQL queries are written here.
  • Formatting Field (Field|Operator|Value|Type|Colors|Cell(0-1)|Colored Area(Optional for Cell value=1): Applies the specified colour, text properties or date format according to the given field.
  • Hide Column Heading: Hides the column headers in the list.
  • Fit Horizontal: Stretches the tool to the full screen width on the user's screen.
  • Pin Right: Pins the tool to the right.
  • Display: Hides the tool on the screen.
  • Detail Button: Adds a detail button to the rows in the report.

Actions

When the row is selected: Actions are added for operations to run when a row is selected.

When double clicked on row: Actions are added for operations to run when a row is double-clicked.



Form Action: An event must be added for the Tree List tool. When the form opens, an Update Value  action is created for the tree list. The screenshot below shows the details of the action created so the tree list runs when the form opens.  

 

Example 1:

Add a Tree List tool to the form and write a query like the one below in its SQL Query field. 

SELECT 1 AS [|id], null AS [|parentId], 'FACULTY OF EDUCATION' AS 'Faculties and Departments', '39' AS Quantity UNION ALL SELECT 2, 1, 'Education Sciences', '16' UNION ALL SELECT 3, 1, 'Department of Computer and Instructional Technology Teacher Education', '2' UNION ALL SELECT 4, null, ' FACULTY OF ENGINEERING' , '21' UNION ALL SELECT 5, 4, 'Department of Computer Engineering','8' SELECT 6, 4, 'Department of Electrical and Electronics Engineering', '13' 

 

The query looks as below on the client screen. 

 

The Search field searches among the values in the list. 

In this query, rows with ids 1 and 4 are treated as top-level because their parentId fields are empty. Rows with Id 2 and Id 3 are under row 1 because their parentId is 1. Likewise, rows with Id 5 and Id 6 are listed under row 4 because their parentId is 4. 

 

Click the triangles on the left to see the values inside.  

 

Formatting (Field|Operator|Value|Type|Colors|Cell(0-1)|Colored Area(Optional for Cell Value=1)); Use this field to colour data in the tree list. Here is a colouring example.

 

Field: Field name to be checked for value 

Operator: Comparison criterion or change format ( for numeric/datetime fields ) 

Value: (to write value to compare) or (to write numeric/datetime format) 

Type: 
0 = To change the text colour 
1 = To change the background colour 
2 = To change the text colour and make the font bold 
3 = To change the text colour and make the font italic 
4 = To change the background colour and make the font bold 
5 = To change the background colour and make the font italic 
right = align text right 
left = align text left 
center = align text centre

Colors: Write the desired colour 

Cell: 
0 To apply the style to the whole row 
1 To apply the style to the selected field

Colored Area: To change the colour of another field instead of the checked value field (Optional for Cell value=1) 

 

In the colouring example above, cells in the Quantity column with a value greater than 20 are painted red. 

In the second line, cells in the parentId column with a value greater than 0 turn blue and their text is shown in italics. 

Resim 47, ResimIn the Tree List tool, rows can be linked to a parent row with the value returned in the parentId field at the end of the query.  

 

 

Resim 46, ResimThe list tree can be thought of as a family tree. If the row a list value belongs to (parentId) is null, it is listed as a parent.

 

 

Example 2:

In our project, design an order entry screen by dragging the needed elements from the form elements on the left and add their queries. After designing, save with the save button marked in red in the screenshot below, press run and switch to the client screen.

 

Enter information by order number on the order screen. Add details. 

In this example 3 order numbers and their details were entered.

Then add a second form to the project and create it as a report. Drag a button and a tree list onto the screen. 

Add the When clicked – Update Value – TreeList_1 action to the button so it triggers the tree list.

Click the Tree List. In its properties on the right, add our query to the SQL Query field.

Add the query below, adapted to your project.

SELECT 0 AS [|DetailID], O.OrderNo AS [|OrderNo], O.OrderNo AS [|id], O.Customer, O.OrderDate, CASE O.Status WHEN 1 THEN 'Processing' WHEN 2 THEN 'Shipped' ELSE 'Delivered' END AS Status, FORMAT(O.TotalAmount , 'N2', 'tr-TR') AS TotalAmount, '' AS Product, '' AS Quantity, '' AS Discount, '' AS UnitPrice, ROUND(SUM(D.TotalPrice),2) AS TotalPrice, NULL AS [|parentId] FROM dbo.XPD_ORDERS O WITH (NOLOCK) LEFT OUTER JOIN dbo.XPD_ORDERS_DETAIL D WITH (NOLOCK) ON O.OrderNo=D.OrderNo GROUP BY O.OrderNo,O.Customer,O.OrderDate,O.Status,O.TotalAmount UNION ALL SELECT UserDetailTableID , O.OrderNo , NULL AS [|id], O.Customer, O.OrderDate, '' AS Status, '' AS TotalAmount, D.Product, FORMAT(D.Quantity, 'N2', 'tr-TR') AS Quantity, FORMAT(D.Discount, 'N2', 'tr-TR') AS Discount, FORMAT(D.UnitPrice, 'N2', 'tr-TR') AS UnitPrice, ROUND(D.TotalPrice,2) AS TotalPrice, D.OrderNo AS [|parentId] FROM dbo.XPD_ORDERS O WITH (NOLOCK) LEFT OUTER JOIN dbo.XPD_ORDERS_DETAIL D WITH (NOLOCK) ON O.OrderNo=D.OrderNo

Points to note when writing the query;

  • For details to open, the ID fields must be given aliases, added as “id” and “parentId”.
  • The “id” alias must be written in lower case exactly like this.
  • For the “parentId” alias, the I is upper case and the rest lower case, exactly like this.
  • The numeric values in the “id” column must be different for each row. 

(In this example, “null” was given for the “id” column in the detail part.)

  • The numeric values in the “parentId” column must contain values from “id”. This is the matching column. Rows whose “parentId” is null are listed as main rows. parentId must not be empty or 0; write it as null.

The screenshot below shows the result of the query above. Detail rows can be opened and closed with the arrow at the start of main rows. The “parentId” of the rows that appear when the arrow is clicked equals the “id” of the clicked main row.

 

Let's colour the rows. Click the tree list element and write the condition in its Formatting Field property. In this example we make main rows blue. Main rows have an “id”; if a condition for “id” greater than 0 is added as in the screenshot below, main rows become blue. 

According to the formatting field above, the tree list looks as below.

The tree list element has two actions: “When the row is selected” and “When double clicked on row”.

Examples for these two actions are below.

Let's start with an action that runs on a single click on a row. 

First add a text box to the form containing the tree list and name it List unit price. Then click the Tree list, choose the action tab in the properties on the right and click add new action. Choose the When the row is selected action.

For When the row is selected, choose the Update Value operation and select the new field in Value Area. In SQL Query, add the UnitPrice field from the list query with $P.

On the client side, after the tree list fills, click the first row. Since the first row has no Unit price, the List Unit Price field gets no data.

When the second row is clicked in the tree list, since it has a unit price, the List Unit Price field gets data.

As a second example, use the When double clicked on row action to open the form where we added the order. In Studio, click the tree list and add it from its actions. For this action, choose the Open Form Linked operation. Choose the Module and Form names. Choose the tree list as the Mapping list. 

In Mapping, click the wizard to match the order entry form with the column names in the tree list. Press Save and Exit to save the action.

 


On the Client screen, double-click one of the main rows in the tree list. The order form window opens. The order number of the selected row is added to the opened order form, and the whole form is updated accordingly.

 

Click a detail row under a main row in the tree list. The order form opens in a new window and fills with that row's order number and detail ID.