| Author |
datatable renders empty rows
|
Demian Seiler
Greenhorn
Joined: Oct 20, 2006
Posts: 11
|
|
Ok, I am pretty sure I know my answer on this one, but I will put it out here in hopes someone has a different response. I have a scenario where I am displaying a list of categorized items. For each category I am displaying a tab. Within each tab is a datatable that lists the items for that specific category. In the datatable I only render the column if the vehicleCategoryID matches the category for the tab selected. So if "Cars" has a categoryID of 1 and "Trucks" has a categoryID of 2 then when the first tab is selected I only render the column if the categoryID is 1. Notice I am using a single datatable here as it is much easier to create, manipulate, and read instead of the 7 different datatables I would have to create otherwise. At first glance this works great. When I click on the "Cars" tab I only see car models and when I click on the "Trucks" tab I see only truck models. The problem with this though is I noticed some odd spacing between some of the rows in the tables. Not horrible, but enough to throw the ui look off. Upon further inspection of the page source I found that the spacing between rows was caused by empty additional <tr> tags being added without any matching <td> tags. This is when I realized that even though the columns were not being rendered due to how I specified the rendered attribute, the rows were still being rendered. I suppose I made a mistake in assuming that if no columns were rendered, the rows would not be rendered either. See the pseudo-code below for an example of what I am talking about. My question is obviously has anyone easily worked around this issue and gotten the <tr> tags to not render. I was hoping for an easy solution as I need to deploy this application shortly, but I am open to any responses on the matter. For example pseudo-code: (datamodel "vehicleDataModel" contains all data for both "Cars" and "Trucks") ... <tab value="Cars"> <datatable value="backing.vehiclesDataModel" var="vehicleData"> <column rendered="#{vehicleData.vehicleCategoryID==1}"> <h utputText value="#{vehicleData.vehicleModel}" /> </column> </datatable> </tab> <tab value="Trucks"> <datatable value="backing.vehiclesDataModel" var="vehicleData"> <column rendered="#{vehicleData.vehicleCategoryID==2}"> <h utputText value="#{vehicleData.vehicleModel}" /> </column> </datatable> </tab> ... Thanks Again, Demian
|
 |
Demian Seiler
Greenhorn
Joined: Oct 20, 2006
Posts: 11
|
|
Ok, well I will respond to my own post. I happened to update from the richfaces 3.0.1 to richfaces 3.1.0 to utilize a new component and as I was testing I noticed my tables appeared to be rendering correctly. So there you have it in case anyone has this issue. Demian
|
 |
Gaurang Panchal
Greenhorn
Joined: Aug 11, 2008
Posts: 5
|
|
Hi Demian, i am currently facing same problem which you have faced. Actually, i am also some bit new for this JSF. Can you tell me which component i should use to remove those empty rows from the table. As of now, I have put a rendered condition at column level but it is anyway rendering empty rows for which the rendered column condision is false. Please reply as soon as possible. Thanks in advance.
|
 |
Demian Seiler
Greenhorn
Joined: Oct 20, 2006
Posts: 11
|
|
Hello, The only change I made to get this to work was to download the following versions of the rich faces jars. richfaces-api-3.1.0.jar richfaces-impl-3.1.0.jar richfaces-ui-3.1.0.jar Other than that I did nothing different. I think this was just a bug in the version of the richfaces datatable. Google on "download richfaces" and you should find the jars Sorry if this doesn't help. Demian
|
 |
Gaurang Panchal
Greenhorn
Joined: Aug 11, 2008
Posts: 5
|
|
Does anybody have any idea? I am still waiting...
|
 |
Gaurang Panchal
Greenhorn
Joined: Aug 11, 2008
Posts: 5
|
|
Finally i have solved my problem... My problem was that, i had problem of unnecessary empty rows in the h:dataTable. The unnecessary <tr> tag has been added without <td> tag inside while i have seen the HTML code of JSF page. It was happening due to conditional rendering of column inside data table. To solve this i have removed the conditional rendering of the column and put "first" and "rows" data members at backing bean. While navigation i set their values and then in JSF page i have put h:dataTable with both of its attribute "first" and "rows" assigned to their specific values in the backing bean.
|
 |
 |
|
|
subject: datatable renders empty rows
|
|
|