Ticket T1287305
Visible to All Users

DataGrid - Using dataRowTemplate for just one row

created 10 days ago

Hello,

is there a way to use dataRowTemplate for just one specific row, and use the usual rows for all other rows?

For context: I'm trying to implement a fake row at the end of the grid (https://supportcenter.devexpress.com/ticket/details/t1284407), but I want to customize its look (merge all cells etc). Or if there is some better way to achieve this.

Thank you
Adam

Answers approved by DevExpress Support

created 10 days ago

Hello Adam,

Thank you for the ticket link.

The dxDataGrid does not allow you to apply dataRowTemplate to a single row. Technically, you can modify the required row through DOM manipulation in the dxDataGrid.onRowPrepared function, but I wouldn't recommend this approach in React. Consider manually rendering the fake row as custom markup outside the grid instead.

If the fake row should be a part of the grid, you can use a custom template for this row as follows:

  • Define the first column's cellRender property. You need to recreate the default cell content in this case. For example:
Code
// <Column dataField="myFirstColumn" cellRender={renderFirstColumn} ... const renderFirstColumn = (cellInfo) => { if (isFakeRow) { // your condition to identify the fake row return (<div>your custom content goes here</div>) } else { return (<div>{cellInfo.text}</div>); // default } }
  • Specify the colspan attribute for the row's first cell and hide other cells in the onRowPrepared function. For example:
Code
const onRowPrepared = (e) => { if (isFakeRow) { // your condition to identify the fake row [e.rowElement.children].forEach((cell, index) => { if (index === 0) { cell.setAttribute('colspan', myColumnCount); } else { cell.style.display = 'none'; } }); } }

You can use this sample as a starting point.

Please let me know if you need further assistance.

    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.