Idea Summary
In the region type of the page, provide a template tree with checkbox. This type of template has these features: it display the tree structure according to the parent-child relationship, selects a checkbox in the leaf node or the middle nodes, and select the checkbox to get the selected value and provides common event processing operations.
Use Case
For example, i have a requirement:
Create a new page that assigns menu permissions to users. At the top of the page is a combination drop-down selection box, which displays user information in a tree structure, displayed at the following levels: Company --> Multi-level Departments --> Persons, which can be filtered according to the characters entered in this box, and finally select a user ID for the following operator's filter conditions.
And, there are two regions on the left and right of the page, the left region displays the unassigned menus permissions tree of the user ID, and the right region displays the assigned menus permissions tree of the user ID. These two tree regions have checkboxes in the leaf nodes or the middle nodes, the checkbox of the leaf nodes can be selected in multiple ways, and the sub checkboxs of the parent node is automatically selected after the checkbox of the parent node is selected.
Under the 2 checkbox tree regions, there are 2 buttons, the left one is the ADD PERMISSIONS button, and the right one is the DELETE PERMISSIONS button. The function of these two buttons is to select the menu permissions in the left tree region, and click ADD PERMISSIONS below to add the selected menu permissions records to the user's permissions table. Similarly, after selecting the menu permissions in the tree region on the right, click DELETE PERMISSIONS below to remove the selected menu permissions records from the user's permissions table. In addition, after adding or deleting permissions, the two regions are refreshed to display the current and latest menu permissions that have not yet been assigned to the user, as well as the assigned menu permissions.
Preferred Solution (Optional)
Provide a template type in the page: TREE WITH CHECKBOX, which can display a tree structure with no limit on the hierarchy according to the parent-child relationship of the data in the table, and can select the checkboxes of leaf nodes or intermediate nodes, if the checkbox of the parent is selected, the checkboxes of all nodes in the subordinate level are automatically selected, and the value of the selected checkbox can be obtained for adding or deleting permissions operations. It also provides code for several commonly used events that can be written to operate.