Create Index Values for Every ID, Instead of Every Row
Create Index Values for Every ID, Instead of Every Row
![hanz](https://secure.gravatar.com/avatar/fd315e9ae67c03a24d881dcfed8e692d/?default=https%3A%2F%2Fvanillicon.com%2Ffd315e9ae67c03a24d881dcfed8e692d_200.png&rating=g&size=120)
Link to test case: http://live.datatables.net/jidaloxe/9/edit
Description of problem: I am using the RowsGroup plugin to merge News Type and Visibility cells for rows with the same ID. The ID column will be hidden but it is visible in the test case for the sake of better understanding. Now I want to add an index column with index values for every ID, instead of every row. The index column code I am using is from here.
Current result:
Desired result: Note: This image is edited, and is not manipulated through code.
Thanks
Hanz
This question has an accepted answers - jump to answer
Answers
Update: http://live.datatables.net/ziluwiki/3/edit
I made some adjustments to the index column creation code. I made it display the same value so I can use RowsGroup to join it later.
Current problem: Everything displays properly except for the last index. For some reason, it keeps looping through that index. I excluded the row from the "if" loop. If I put an "else", all indexes will be the same value.
Please help me with this issue.
Thanks
Hanz
Update: http://live.datatables.net/ziluwiki/6/edit
I replaced the ID column with index values. However, the last index is still the ID value.
I'm not clear on what you are trying to do but the
order.dt search.dt
event handler will be called multiple times on initialization as Datatables will perform order and searching when the table is built. One problem is you need to initialize thecounter
andindex
variables inside the event so the reset each time the event handler executes.http://live.datatables.net/ziluwiki/7/edit
Not sure if this fixes your problem but hope it gets you closer.
Kevin
Solution: http://live.datatables.net/ziluwiki/10/edit
Issue 1 Solution:
I did an "else if" to solve the last index issue as it was outside of the if condition.
Issue 2 Solution:
The index numbers did not adapt to the rows when search is applied, so I changed the data source from all records to only sorted records displayed.
New data source:
sortedNews = table.rows({ filter: 'applied' }).data();
Hope this helps anyone who is attempting to do an index column for merged rows! DataTable, please support this as an API in the future!