I have a table right now that contains a button in each row called “Edit”. When I call that it makes the whole table editable. How would I go about making only one row editable depending on which button you pressed?
Another similar question… How can I make only certain properties editable in the table? Meaning, how can I have text fields appear only for certain properties?
You can achieve both results with a customized TableFieldFactory set for the table. If you return null in createField method, the cell will be displayed like in non-editable table. I just refined the javadocs a bit as it was not that well emphasized there.
I’m trying to do that. I figured the answer would come from TableFieldFactory. Here’s a little bit of code that gets called whenever an Edit button is pressed. It gets called via a listener because the button is inside of the bean that the table is made out of.
So this should have made the whole table uneditable because I returned null every time. But every cell still had a textfield and it doesn’t look like it was ever called because the println’s never printed out.
So I’m still a little bit lost. Thank you for your patience because I’m sure I’m missing something very obvious. Haha.
About the readonly issue. I think that the information if a prop is readonly or not should come from the property itself. If your properties handle that info correct then you dont have to hack the FieldFactory at all because Fields will be editable or not based on their propertydatasource.
For the other question. I had a similar problem. i just wanted to make a single table row editable when a user clicks on it. I think theres no standard widget but you can workarround it with a generated column a customcomponent as inline editor and a click listener wich activates the clicked row and deactivates all others.
That works great…
But when the text field appears in the table cell it doesn’t automatically expand the column to adjust it. The column does resize after you refresh the page. Is there a work around for that?