Ticket T204532
Visible to All Users

How to show expand button only on items which have children

created 10 years ago

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.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Tanveer,

Please handle the onRowPrepared event to hide an expand button for required rows. For example:

JavaScript
onRowPrepared: function (info) { if (condition) info.rowElement.find('td:nth-child(1)').removeClass("dx-datagrid-group-closed"); }
    Show previous comments (3)
    DevExpress Support Team 10 years ago

      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:

      JavaScript
      onContentReady: 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.

        Thank you that helps.

        DevExpress Support Team 10 years ago

          You're always welcome, Tanveer!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.