How to show expand button only on items which have children? Using css or jquery to hide them messes up the UI padding and all. Is there a way to do it from the API.
How to show expand button only on items which have children
Answers approved by DevExpress Support
Hello Tanveer,
Please handle the onRowPrepared event to hide an expand button for required rows. For example:
JavaScriptonRowPrepared: function (info) {
if (condition)
info.rowElement.find('td:nth-child(1)').removeClass("dx-datagrid-group-closed");
}
Tanveer,
In this case, I suggest you expand each row manually using the expandRow(key) method in the dxDataGrid.onContentReady event handler as shown below:
JavaScriptonContentReady: function (e) {
// if (condition)
var count = e.component.pageSize();
for (var i = 0; i < count; i++)
// if (condition)
e.component.expandRow(i);
}
Note that the onContentReady event fires each time a user performs a grid action. So, you need to add a condition for cases when you do not want to expand all non-empty rows. I've also attached a sample project that illustrates the issue in action.