Column rendering depending on editing state
Column rendering depending on editing state
Titania
Posts: 6Questions: 3Answers: 0
Is it possible to render column depending on some state/attribute/etc?
I have table that shows only id and name, but it also has EDIT button in the last column.
I would like to render column with name attribute like an input element with name value when EDIT button is selected and like normal text otherwise. How can I achieve this kind of behavior?
This discussion has been closed.
Answers
Sure - use a renderer. You can use it as a function, so you can use whatever logic conditions you want in it.
Allan
Hmmm - actually, that would require a rerender on each state change. You could call
rows().invalidate()
to do that if that is what is needed.Allan
Thank you for your answer. I managed to do it using render function and rows().invalidate() but I have one more question. Currently I'm using some variable "editing" defined outside table definition and my render function looks like this:
Is there any better way than using variable? I wanted to add class "editing" to <tr> element being edited but I don't have reference to it in render function.
Thank you!
The only other way would be to add an
editing
parameter to the row's data object. As you say, therender
function doesn't really have access to the node (since it is possible that it will be called before the node exists).Allan