Recently, I was facing a problem with the p:datatable colspan attribute.
I wanted to conditionally colspan the table cell, but I failed to do that. And I found its impossible to do it now from the Primefaces forum.
Finally, I came out with a workaround with jQuery.
Instead of the colspan attribute, I used the styleClass attribute to dynamically adjust the table's colspan.
Platform: Primefaces 3.4
Server: Tomcat 7
Steps:
1. Declare the styleClass attribute with dynamic conditions.
2. Declare the jQuery script to adjust the table colspan on page loading.
Done!!
With the above steps, jQuery will dynamically adjust the table colspan based on the passed in conditions.
I wanted to conditionally colspan the table cell, but I failed to do that. And I found its impossible to do it now from the Primefaces forum.
Finally, I came out with a workaround with jQuery.
Instead of the colspan attribute, I used the styleClass attribute to dynamically adjust the table's colspan.
Platform: Primefaces 3.4
Server: Tomcat 7
Steps:
1. Declare the styleClass attribute with dynamic conditions.
2. Declare the jQuery script to adjust the table colspan on page loading.
- above script showed the jQuery lookup any element where className = 'myStyleClass', then adjust the colspan attribute with my desired value.
- myStyleClass is just a unique name for jQuery to lookup the element, it could be any name.
- 4 is just an example, it could be any desired colspan value.
Done!!
With the above steps, jQuery will dynamically adjust the table colspan based on the passed in conditions.
That helped me, thanks
ReplyDelete