0

I'm using PrimeFaces 5.1, In my page I need dataTable width through expression,because p:columns to set column at the dataTable with greater 400px set auto otherWise set width 400px;

<p:dataTable id="cars" var="car" value="#{dtColumnsView.cars}" 
widgetVar="carsTable" filteredValue="#{dtColumnsView.filteredCars}" 
style="width:expression(this.Width >400 ?'auto':'400px')">                   
<p:columns value="#{dtColumnsView.columns}"
var="column" columnIndexVar="colIndex" 
sortBy="#{car[column.property]}" filterBy="#{car[column.property]}">
                    ..........
</p:columns>
</p:dataTable>

I need to set width through expression below width expression is not working?

SVN
  • 21
  • 1
  • 7
  • 1
    What is `this` there? And where are you using EL notations there (`#{}`)? It neither appears to be a JavaScript function. Is it an enhanced syntax of HTML 5 or JSF `passthrough` which I am possibly not aware of? Simply saying "*not working*" and then remaining mute forever will not help solve the problem. – Tiny Dec 23 '15 at 10:29
  • Try using `style="min-width: 400px;"`. – Geinmachi Dec 23 '15 at 10:36
  • 1
    @Tiny: it's called a CSS expression. It's a 90's MSIE proprietary thing which should be avoided at all cost in modern web development. See also http://stackoverflow.com/questions/6191679/css-expressions and http://google.com/search?q=css+expression. OP should in this specific case have used `@media` queries and/or `max-width`/`min-width` instead. The `@media` existed long, but a lot of starters are completely unaware how it could be used in responsive design, and `min-width`/`max-width` was "only" introduced in CSS2 (1998 already, mainstream since ~2000). – BalusC Dec 23 '15 at 12:11

1 Answers1

0
<p:dataTable id="cars" var="car" value="#{dtColumnsView.cars}" 
widgetVar="carsTable" filteredValue="#{dtColumnsView.filteredCars}" 
style="width:400px;text-align: center;margin: 0 auto;">  

use this style it will work