Is it possible to alternate color row in the virtual table with Tree data?
I added a persistent row index to identify a row bud it is no best solution:
https://codesandbox.io/s/yv1wopw239
Are you a workaround?
Carlo
Hi,
Let's take a look at your example.
The following line adds a row index for each row:
const dataWithRowIndex = data ? rows.map((row, index) => ({ ...row, rowIndex: index })) : data;
Then, you pass the聽dataWithRowIndex聽array to the聽rows聽property of the聽Grid聽component. Next, you use the聽CustomTreeData聽plugin. As you can see in our聽documentation, the聽CustomTreeData plugin modifies Grid rows. That's why your row indices don't make sense. At the same time, the聽TableTreeColumn plugin聽exports聽the聽tableBodyRows聽Getter, which contains rows that will be rendered. Thus, you can override this Getter to apply a row index:
const tableBodyRowsComputed = ({ tableBodyRows }) =>
tableBodyRows.map((tableBodyRow, i) => ({
...tableBodyRow,
ROW_INDEX: i
}));
<Getter name="tableBodyRows" computed={tableBodyRowsComputed} />
Then, you can use the聽ROW_INDEX聽field to highlight odd rows.
I've聽updated聽your sample as well.
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests.
Most helpful comment
Hi,
Let's take a look at your example.
The following line adds a row index for each row:
Then, you pass the聽
dataWithRowIndex聽array to the聽rows聽property of the聽Grid聽component. Next, you use the聽CustomTreeData聽plugin. As you can see in our聽documentation, the聽CustomTreeDataplugin modifiesGridrows. That's why your row indices don't make sense. At the same time, the聽TableTreeColumnplugin聽exports聽the聽tableBodyRows聽Getter, which contains rows that will be rendered. Thus, you can override this Getter to apply a row index:Then, you can use the聽
ROW_INDEX聽field to highlight odd rows.I've聽updated聽your sample as well.