I would like to swap two columns in JSF h:dataTable based on a condition. For instance if a user chooses red, then the column with red values comes first. If he chooses the other color say blue then the column with blue values comes first and the other afterwards.
I have played with the rendered attribute but it is not working.
If you use Primefaces you can bind the columns to a collection in the server side, so you can filter and rearrange columns as you like
Example:
https://www.primefaces.org/showcase/ui/data/datatable/columns.xhtml
With plain JSF I don't think that's possible, but you could go with a client approach such reordering the <td> elements with jQuery.
Related
I'm planning on rendering a list that contains nested tables.
If, for example, a row happens to contain a table containing 100s of items, would react-virtualized break up that row? Or would it render the entire row no matter its height, therefore defeating the purpose of virtualized infinite scroll?
Looks like the answer is a no:
https://github.com/bvaughn/react-virtualized/issues/980
I would like to render a group of name-value only if a value is not null (or another condition). This group of name is among other names and values which are always rendered.
To format the page, I use a <h:panelGrid columns="2">.
If I use a <h:panelGroup rendered='thecondition'> the alignment does not work. I tried <ui:fragment> and it didn't work either.
The group contains a large number of values and I would like not to add a rendered attribute for each name and each value of the group. Is there another solution?
I have done this many times before in other platforms where a data table is rendered through a loop and I had more control. However, h:dataTable is more high level and I can't or don't know how to embed a function on the row level that will color the background of the row differently based on whether it is an even or odd numbered row.
Is it possible and how can I rows in h:dataTable alternate color?
Just have two classes oddRow and evenRow in the css having different background colors then use rowClasses="oddRow,evenRow" to apply the different background of the rows
I have a view that displays data from several categories, where the category (bug severity in my case) is color-coded into the background color of individual entries. Now I'd like to apply the same background color to the category line itself.
As the column setting the background color for the rest of the line isn't displayed in category rows, the setting isn't applied. Is there a workaround for that?
Taken from: http://www-10.lotus.com/ldd/nd6forum.nsf/0/2765b9380021c666852572d800589f9d?OpenDocument
Here is an awkward method that works to color your category rows
differently.
Put a column before all the categorized columns. This will be your color column. Check the Use Value as Color property of the column
properties.
Use one of the functions below:
#If(#IsCategory("any")="any";any;1:1:1)
#If(#IsCategory("x")="y";z;1:1:1)
Note: in the function above, where the word "any" appears, or "x" "y"
and "z", it can be anything, matching or not. It will always evaluate
to false. If you try just #IsCategory, it will error out because that
doesn't return true. And no match you try will ever cause a true
comparison.
That said, the result is that all rows will be colored black if they
are not categories. This overrides the default text color. If you want
another color than black, then adjust the 1:1:1 accordingly
(red:green:blue up to 255 for each position, red= 255:0:0)
Now go to any column and set the text color to the row you want your
categorized rows to appear in, and click Apply to All. Voila!
I was trying to figure out how to do this programmatically and then I wondered, why not just borrow from the mail template? I'd like to suggest you check into how the ColorProfile is used there to allow users to change their color preferences based on a field value (sender name) and see if it can be done for your case.
Or, have them either access the view via a browser client or XPages in the Notes client and assign a class to that dependent on the severity.
You could build the category column formula with HTML such that when it is severe the value is "<tr class='severe'><td>CategoryNameValueHere</td></tr>" or something along those lines, right?
Im using glassfish 3.0.1 and was experimenting with columnClasses in dataTable for the first time.
It's something like this :
<h:dataTable value="#{coreGridBean.heroBeanList}" var="hero"
captionStyle="font-size: 0.95em; font-style:italic"
styleClass="orders"
headerClass="ordersHeader"
footerClass="ordersHeader"
columnClasses="oddColumn,evenColumn">
From the core jsf book im reading, it says that by specifying only 2 classes in the columnClasses attribute, those 2 will be repeated when the column amount is more than 2.
Let's say that i have five columns, the columnClasses would become something like oddColumn,evenColumn,oddColumn,evenColumn,oddColumn, and we just need to define it like this : columnClasses="oddColumn,evenColumn"
But in my experience with 3 columns, it's not like this. From the third column they got no classes. I had to specify columnClasses="oddColumn,evenColumn,oddColumn" to make it work
Is this a bug or i just have a bad error ?
The repetition only applies on rowClasses.
From the JSF 2.0 h:dataTable tag documentation:
columnClasses
Comma-delimited list of CSS style classes that will be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of actual column children of the UIData, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of actual column children of the UIData, the elements at the posisiton in the list after the last column are ignored.
rowClasses
Comma-delimited list of CSS style classes that will be applied to the rows of this table. A space separated list of classes may also be specified for any individual row. Thes styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again.
Maybe the book was wrong, or you misread the book.
Since the column number is usually always fixed in the view definition anyway, it's little effort to just repeat them yourself.
<h:dataTable columnClasses="oddColumn,evenColumn,oddColumn,evenColumn">
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
</h:dataTable>