You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@cs.tu-dortmund.de> on 2010/03/30 16:28:38 UTC

Grid: Customizing cell CSS based on property value

Hi!

Is it possible to change the class of a grid cell (not just the row or 
column) based on the value of the property?

For example I want to display all cells with the String "Correct" green 
and those with "Incorrect" in red.

TIA
  Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by Dmitry Gusev <dm...@gmail.com>.
Give it another try, like this:

    <style>
       table.t-data-grid tbody tr td.lastPingSummary { /* here may be
selector for your column */
           padding: 0px; /* remove padding from all column cells to avoid
left and right space */
       }
       .red {
           background-color: red;
           line-height: 20px; /* set div's line height to remove top-bottom
space */
           padding-left: 2px; /* add some padding to your div */
           padding-right: 2px;
       }
    </style>

    <t:grid empty="No jobs" source="jobs" row="job" ...>

        <t:parameter name="lastPingSummaryCell">
            <div class="${summaryStatusCssClass},
red">${lastPingSummary}</div>
        </t:parameter>

I just checked this on my app - its working as expected. But I'm using
different way to highlight cells in my app: I'm changing text color in my
div's, I think this looks prettier :)

HTH

On Thu, Apr 1, 2010 at 15:21, Stephan Windmüller <
stephan.windmueller@cs.tu-dortmund.de> wrote:

> Am 01.04.2010 12:28, schrieb matias.blasi:
>
>
>  page.tml:
>>
>> <t:grid t:source="objects" t:row="o">
>>      <p:somepropertycell>
>>          <div class="${somestyleclass}">${o.someproperty}</div>
>>      </p:somepropertycell>
>> </t:grid>
>>
>> app.css:
>>
>> .somestyleclass {
>>    background-color:red;
>>    width: 100%;
>>    height: 100%;
>> }
>>
>> doesn't it works?
>>
>
> No, this was my first try. ;)
>
>
> - Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Re: Grid: Customizing cell CSS based on property value

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 01.04.2010 12:28, schrieb matias.blasi:

> page.tml:
>
> <t:grid t:source="objects" t:row="o">
>       <p:somepropertycell>
>           <div class="${somestyleclass}">${o.someproperty}</div>
>       </p:somepropertycell>
> </t:grid>
>
> app.css:
>
> .somestyleclass {
>     background-color:red;
>     width: 100%;
>     height: 100%;
> }
>
> doesn't it works?

No, this was my first try. ;)

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by "matias.blasi" <ma...@gmail.com>.
page.tml:

<t:grid t:source="objects" t:row="o">
     <p:somepropertycell>
         <div class="${somestyleclass}">${o.someproperty}</div>
     </p:somepropertycell>
</t:grid>

app.css:

.somestyleclass {
   background-color:red;
   width: 100%;
   height: 100%;
}

doesn't it works?


Stephan Windmüller-8 wrote:
> 
> On 31.03.2010 20:31 matias.blasi wrote:
> 
>> Although Tapestry Grid don't allow you to specify cell CSS style, you can
>> do
>> something like this:
>>
>> <t:grid t:source="objects" t:row="o">
>>      <p:somepropertycell>
>>          <div class="somepropertystyleclass">${o.someproperty}</div>
>>      </p:somepropertycell>
>> </t:grid>
> 
> Of course, but I want to change the background-color of the whole cell.
> 
> - Stephan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Grid%3A-Customizing-cell-CSS-based-on-property-value-tp28083380p28106874.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
On 31.03.2010 20:31 matias.blasi wrote:

> Although Tapestry Grid don't allow you to specify cell CSS style, you can do
> something like this:
>
> <t:grid t:source="objects" t:row="o">
>      <p:somepropertycell>
>          <div class="somepropertystyleclass">${o.someproperty}</div>
>      </p:somepropertycell>
> </t:grid>

Of course, but I want to change the background-color of the whole cell.

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by "matias.blasi" <ma...@gmail.com>.
Hi!

Although Tapestry Grid don't allow you to specify cell CSS style, you can do
something like this:

<t:grid t:source="objects" t:row="o">
    <p:somepropertycell>
        <div class="somepropertystyleclass">${o.someproperty}</div>
    </p:somepropertycell>
</t:grid>

Don't you?

Regards.
Matías.


Thiago H. de Paula Figueiredo wrote:
> 
> On Wed, 31 Mar 2010 09:21:04 -0300, Stephan Windmüller  
> <st...@cs.tu-dortmund.de> wrote:
> 
>> On 30.03.2010 16:34 Thiago H. de Paula Figueiredo wrote:
>>
>>>> Is it possible to change the class of a grid cell (not just the row or
>>>> column) based on the value of the property?
>>> Yes! Just use the rowClass parameter.
>>
>> But this changes only the class of the tr element like:
> 
> Oops, I misread your question. I'm sorry. Grid currently hasn't a way of  
> specifying a cell CSS class.
> 
>> Of course I could change the rowClass and use CSS selectors and the  
>> property id but I am wondering if there is another way.
> 
> AFAIK, there isn't. If you want, you can file a JIRA for that.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da  
> Informação Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Grid%3A-Customizing-cell-CSS-based-on-property-value-tp28083380p28099971.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 31 Mar 2010 09:21:04 -0300, Stephan Windmüller  
<st...@cs.tu-dortmund.de> wrote:

> On 30.03.2010 16:34 Thiago H. de Paula Figueiredo wrote:
>
>>> Is it possible to change the class of a grid cell (not just the row or
>>> column) based on the value of the property?
>> Yes! Just use the rowClass parameter.
>
> But this changes only the class of the tr element like:

Oops, I misread your question. I'm sorry. Grid currently hasn't a way of  
specifying a cell CSS class.

> Of course I could change the rowClass and use CSS selectors and the  
> property id but I am wondering if there is another way.

AFAIK, there isn't. If you want, you can file a JIRA for that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
On 30.03.2010 16:34 Thiago H. de Paula Figueiredo wrote:

>> Is it possible to change the class of a grid cell (not just the row or
>> column) based on the value of the property?
> Yes! Just use the rowClass parameter.

But this changes only the class of the tr element like:

<table>
  <tr class="rowClass">
   <td> ... </td>
  </tr>
</table>

What I want to do is customizing the cell, not the row:

<table>
  <tr>
   <td class="cellClass"> ... </td>
  </tr>
</table>

Of course I could change the rowClass and use CSS selectors and the 
property id but I am wondering if there is another way.

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Grid: Customizing cell CSS based on property value

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 30 Mar 2010 11:28:38 -0300, Stephan Windmüller  
<st...@cs.tu-dortmund.de> wrote:

> Hi!

Hi!

> Is it possible to change the class of a grid cell (not just the row or  
> column) based on the value of the property?

Yes! Just use the rowClass parameter.

> For example I want to display all cells with the String "Correct" green  
> and those with "Incorrect" in red.

Something like this:

<table t:type="Grid" t:rowClass="rowClass">

public String getRowClass() {
	...
}

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org