How to add an event-handler (show/hide child) to certain rows and not to all?
How to add an event-handler (show/hide child) to certain rows and not to all?
mariokitz
Posts: 4Questions: 2Answers: 0
In all child examples a plus/minus icon and event handler is added to each row of a datatable. I only have certain rows that will contain a child row and only these rows with a child should have the plus/minus icon and the onclick event handler to show/hide the child. Probably very easy but I am new to this topic. Thanks for your help!
This discussion has been closed.
Answers
I would suggest using
createdRow
to conditionally add a class to the row based on whatever condition it is that you need. The event handler and also the icon should then reflect that class.Allan
Thanks a lot allan, but the createdRow function does not fire once a child is added. It seems to be firing only if a "normal" row is created. If it does fire, how do I determine if a row has a child and how do I add the class "details-control" to the first column of that row (the first td in that row)?
Hi Allan, the createdRow idea let me in the right direction. This is working for me now:
That looks good to me. Thanks for posting back.
Allan