We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Is there a way to not render command buttons for certain rows in a TreeGrid.

If I configure a tree grid column to use Command Buttons, is there a way to configure it so the buttons only show up for Parent rows, child rows, or some combination of them based on the data source?

1 Reply

MP Manivannan Padmanaban Syncfusion Team May 31, 2019 11:28 AM UTC

Hi John, 

Thanks for contacting Syncfusion Support. We are happy to assist you. 

Query: If I configure a tree grid column to use Command Buttons, is there a way to configure it so the buttons only show up for Parent rows, child rows, or some combination of them based on the data source? 
 
From the above query, we are able to understand that you want to show the command buttons only for the parent rows. Here, we have showed the command button only for the rows which is having child records using queryCellInfo event of TreeGrid. Kindly refer the below code example, 

<script type="text/javascript"> 
 
 
    var onclick = function (args) { 
        alert("hit");  // do your stuff here 
    } 
    var onQueryCellInfo = function (args) { 
        if (!args.data.hasChildRecords) { 
            if (args.cell.classList.contains("e-unboundcell")) { 
                args.cell.querySelector('.e-unboundcelldiv').style.display = "none" 
            } 
        } 
    } 
 
    let grid: TreeGrid = new TreeGrid( 
        { 
…………………………… 
            queryCellInfo: onQueryCellInfo, 
            columns: [ 
                { 
                    …………….. 
 
                { 
                    headerText: 'Custom Button', width: 100, 
                    commands: [ 
                        { buttonOption: { content: ' Details', click: onclick } }] 
                } 
            ] 
        }); 
    grid.appendTo('#Grid'); 
 




Regards, 
Manivannan Padmanaban. 




Loader.
Up arrow icon