I have a requirement, where there is a datatable with some rows.. Each row will have a '[+]' link. On click of that link, I need to display some details concerning that row. The details of that row should again be displayed in a Datatable. Can you please let me know how to implement the same.
I have the below requirement.
Before expansion, the below data should be displayed.
Where did you get this "selection=" attribute from? It's not a documented feature in JSF.
It would help if you indented your XML so that the structure would be more obvious. One thing I did notice that I don't recommend is that you used a raw HTML "div" tag. Avoid using raw HTML when possible.
Beyond that, put "id=" attributes on all input and output controls (including buttons and links). That way you'll get a more meaningful indication on your error message.
Thanks for the response. As you specified there is no selection attribute in JSF. That was a Typo. Please find the below code that I have written to get the subtable details. I have addressed your comments in the below code. But still the subtable does not seem to get rendered.
Only the parent table seems to render. The subtable does not seem to render. Am I missing something?? Please help.
When I put the datatable inside the cell(column) of the parent table, it results in column expansion. Which is not my requirement. I wanted the child datatable to appear after the first row. Please assist.
When I put the data table inside the cell(column) of the parent table, it results in column expansion. Which is not my requirement. I wanted the child data table to appear after the first row. Please assist.
It looks like you want a 3-column subtable to appear as an extension to selected rows of a 4-column parent table.
That's pretty sticky, especially since (as numerous disgusted people have noted), JSF dataTables don't support rowspan or colspan constructs.
There are 2 possibilities I can think of offhand.
1. Use an extension tagset that allows this kind of thing. I think one of the RichFaces extended datatables might be employable for that use.
2. Construct your own. You might want to make a Facelets component object (custom tag) out of this. At a rough guess, I'd say use a ui:repeat to render the outer table as a set of 4-colum table slices each optionally followed by a 3-column subtable. Despite all the ranting I do about ui:repeat, there are times when it's a very useful thing to have. Just not as often as some people think.
The child table is appearing fine. However only on the first row. I.e For Eg: Consider the parent table has 4 Rows of data. As per the logic that I have written, Onclick of the image in the first row only im able to get the child datatable. When I click on the images in the other rows, the rowexpansion is not happening. The child table seems to appear only in the first row. I have included the child table with the ui:repeat. but still it does not seem to render. Please Assist.
There are 2 reasons why it's a good idea to distill your examples down to the bare minimum of code/XML.
1. It helps you solve your own problems. The less code there is, the fewer places things can go wrong.
2. I don't get paid for this, so I can't afford to spend much time in in-depth analysis on problems people present on the JavaRanch. So my evaluations are fairly superficial. Long examples require a lot of reading to sort the important stuff from the unimportant stuff and I can't spare that much time.
Thanks a lot for the Inputs Tim. Really Appreciate your help. As specified by you, I have limited the lines of code and was identify the issue. Now its resolved. The Subtable is appearing in all the rows of the datatable.