Articles in this section
Category / Section

How to re-arrange the custom toolbar items in front position of Tree Grid toolbar list?

2 mins read

This Knowledge base explains how to re-arrange the custom toolbar items in front position of Tree Grid toolbar list

 

Solution

Using insertBefore method of JavaScript, we have re-arranged the toolbar items in created event of Tree Grid.

JS

let treegridObj: TreeGrid = new TreeGrid(
    {
        dataSource: sampleData,
        allowFiltering: true,
        editSettings: { allowAdding: true, allowEditing: true, allowDeleting: true, mode: 'Cell', newRowPosition: 'Below' }, toolbar: ['Add', 'Delete', 'Update', 'Cancel', 'ExpandAll', 'CollapseAll', { text: 'Quick Filter', tooltipText: 'Quick Filter', id: 'toolbarfilter' }],
        toolbarClick: (args: ClickEventArgs) => {
            if (args.item.id === 'toolbarfilter') {
                treegridObj.filterByColumn('taskName', 'startswith', 'Testing');
            }
        },
        childMapping: 'subtasks',
        allowPaging: true,
        treeColumnIndex: 1,
        created: function () {
            let items =  treegridObj.toolbarModule.getToolbar().children[0]; // get the toolbar items.
            for (let i = 1; i < items.childNodes.length; i++) {
                items.insertBefore(items.childNodes[i], items.firstChild); // re-arrange the toolbar items position
            }
        },
        columns: [
            { field: 'taskID', headerText: 'Task ID', isPrimaryKey: true, textAlign: 'Right', width: 90 },
            { field: 'taskName', headerText: 'Task Name', width: 130 },
            { field: 'startDate', headerText: 'Start Date', width: 90, textAlign: 'Right', format: 'yMd' },
        ]
    });
treegridObj.appendTo('#TreeGrid');
 

 

toolbar position re-arrangement

Figure 1 Toolbar position customization

 

JavaScriptDemo

Also refer the other frameworks demo links below,

AngularDemo

ReactDemo

VueDemo

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied