Responsive extension: column class not retained for cells in expanded rows
Responsive extension: column class not retained for cells in expanded rows
I am using columnClass property to assign different rendering (and event processing) to cells belonging to different columns.
When the table fits within the screen every <td> element gets the class as specified by the columnClass property of its column and I can easily hook some rendering/processing functions to the <td> elements.
However, when some of the columns don't fit within the page and I expand the row (by clicking the '+' button) the cells are renedered with no reference to the class of the column. I reviewed the custom renderer for the cells of the expanded columns and also see no way finding out what the column class of a cell is.
Ideally, I would like to use the same custom field renderer as defined in the table. Is there a way I can do it?
Example:
Let's say I have 3 columns: name, dob, salary.
I defined 3 classes for the columns: name_class, dob_class, salary_class.
For each class I use a jquery selector and assign diffrerent rendering/behavior for each cell of that column.
Now, I resize the table so that dob and salary get overflown and click on the '+' button to expand the row of interest.
I would expect to get the dob cell with the dob_class attribute and salary cell with the salary_class attribute, so I am able to link the same cell renderer to them. However, ****the class attribute is no assigned (not retained) and I cannot link with jquery using the class attribute. ****
**Could you please suggest an solution that would allow me to retain the column class on the cells of the expanded row? **
Answers
Hi @vizakhar.microsoft ,
Sorry, no, that's not currently possible. It has been raised against the code already, see https://github.com/DataTables/Responsive/issues/93, so it is on the todo list.
Cheers,
Colin
Thank you very much for your response!
Is there a chance you could suggest a reasonable workaround? I am looking to somehow determine what the columnClass is when I render an expanded cell in a custom row renderer.
Hi again,
One workaround would be to reapply those classes as part of the rendering, see this example here: https://datatables.net/extensions/responsive/examples/child-rows/custom-renderer.html
There, the render is creating the rows, you could do the same, while also adding the class specific for each row.
Hope that helps,
Cheers,
Colin