You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ashika Umanga Umagiliya <au...@biggjapan.com> on 2010/02/04 03:28:05 UTC

DataTable : Setting the Column with from Java ?

Greetings,

For my DataTable ,I create 'IColumn's using data from an XML file.

In the code-snippet below, the 'vcol' instance has information about 
Column-title,bean property field,visible or not..etc.
Now I want to set the column width using the same way.How can I change 
the CSS property from Java ?
Any tips how I can do this?



List<IColumn> columns;
//For each Column in Table
for (Column vcol : table.getColumns()) {
            if (!vcol.isVisible()) {
                continue;
            }

            if (vcol.getId().equals("id")) {
               
                AbstractColumn<E> linkcolumnModel=null;
                if(vcol.isSort()){
                    linkcolumnModel=new SortableIdColumn(new 
Model(vcol.getTitle()),vcol.getValue());
                }else{
                    linkcolumnModel=new SortableIdColumn(new 
Model(vcol.getTitle()));
                }

                columns.add(linkcolumnModel);

            } else if (vcol.isLinkout()) {
                LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
                        .getTitle()), vcol.getValue());            
                columns.add(linkoutCol);
            } else {
                //Add normal datacolumn
                if(vcol.isSort()){
                    columns.add(new PropertyColumn<String>(new 
Model(vcol.getTitle()),
                             vcol.getValue(),vcol.getValue()));            
                }else{
                    columns.add(new PropertyColumn<String>(new 
Model(vcol.getTitle()),
                             vcol.getValue()));                        
                }
                
          }

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


Re: DataTable : Setting the Column with from Java ?

Posted by Ashika Umanga Umagiliya <au...@biggjapan.com>.
Hi nino,

I just use
    <table wicket:id="table" cellspacing="0" width="100%" class="grid">

to display my datatable.
I dont want to change the CSS style for the class.I want the change the 
width of each Column ,according to the value read from XML.
Something like:

int colWidth=vcol.getColumnWidth();

IColumn col;
..
..
col.someMethod().editAttribute("width",colWidth);
..



nino martinez wael wrote:
> I susspect you should add the attribute modifier to your LinkoutColumn
> telling what css class you want to use.. I would have to see the html aswell
> to help further..
>
> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>
>   
>> Hi nino,
>>
>> To which component I should add an attribute-modifier. In IColumn ,i should
>> add the 'width' to the headers ,i assume.
>> any tips to do this?
>>
>>
>> nino martinez wael wrote:
>>
>>     
>>> use a attribute modifier
>>>
>>>
>>> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>>>
>>>
>>>
>>>       
>>>> Greetings,
>>>>
>>>> For my DataTable ,I create 'IColumn's using data from an XML file.
>>>>
>>>> In the code-snippet below, the 'vcol' instance has information about
>>>> Column-title,bean property field,visible or not..etc.
>>>> Now I want to set the column width using the same way.How can I change
>>>> the
>>>> CSS property from Java ?
>>>> Any tips how I can do this?
>>>>
>>>>
>>>>
>>>> List<IColumn> columns;
>>>> //For each Column in Table
>>>> for (Column vcol : table.getColumns()) {
>>>>          if (!vcol.isVisible()) {
>>>>              continue;
>>>>          }
>>>>
>>>>          if (vcol.getId().equals("id")) {
>>>>                            AbstractColumn<E> linkcolumnModel=null;
>>>>              if(vcol.isSort()){
>>>>                  linkcolumnModel=new SortableIdColumn(new
>>>> Model(vcol.getTitle()),vcol.getValue());
>>>>              }else{
>>>>                  linkcolumnModel=new SortableIdColumn(new
>>>> Model(vcol.getTitle()));
>>>>              }
>>>>
>>>>              columns.add(linkcolumnModel);
>>>>
>>>>          } else if (vcol.isLinkout()) {
>>>>              LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>>>>                      .getTitle()), vcol.getValue());
>>>>    columns.add(linkoutCol);
>>>>          } else {
>>>>              //Add normal datacolumn
>>>>              if(vcol.isSort()){
>>>>                  columns.add(new PropertyColumn<String>(new
>>>> Model(vcol.getTitle()),
>>>>                           vcol.getValue(),vcol.getValue()));
>>>>            }else{
>>>>                  columns.add(new PropertyColumn<String>(new
>>>> Model(vcol.getTitle()),
>>>>                           vcol.getValue()));
>>>>        }
>>>>                      }
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>>     
>
>   


Re: DataTable : Setting the Column with from Java ?

Posted by nino martinez wael <ni...@gmail.com>.
In my point of view. Thats prettier done/more clean with a dynamic css.. But
there's some way for you to get there.

regards Nino

2010/2/5 Ashika Umanga Umagiliya <au...@biggjapan.com>

> Thanks for the tips,
>
> I found the solution:
>
> public void populateItem(Item<ICellPopulator<E>> cellitem,
>               String id, IModel<E> model) {
>              cellitem.add(new
> SimpleAttributeModifier("style","width:"+width+"px"));
> }
>
> regards
> umanga
>
> nino martinez wael wrote:
>
>> I susspect you should add the attribute modifier to your LinkoutColumn
>> telling what css class you want to use.. I would have to see the html
>> aswell
>> to help further..
>>
>> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>>
>>
>>
>>> Hi nino,
>>>
>>> To which component I should add an attribute-modifier. In IColumn ,i
>>> should
>>> add the 'width' to the headers ,i assume.
>>> any tips to do this?
>>>
>>>
>>> nino martinez wael wrote:
>>>
>>>
>>>
>>>> use a attribute modifier
>>>>
>>>>
>>>> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Greetings,
>>>>>
>>>>> For my DataTable ,I create 'IColumn's using data from an XML file.
>>>>>
>>>>> In the code-snippet below, the 'vcol' instance has information about
>>>>> Column-title,bean property field,visible or not..etc.
>>>>> Now I want to set the column width using the same way.How can I change
>>>>> the
>>>>> CSS property from Java ?
>>>>> Any tips how I can do this?
>>>>>
>>>>>
>>>>>
>>>>> List<IColumn> columns;
>>>>> //For each Column in Table
>>>>> for (Column vcol : table.getColumns()) {
>>>>>         if (!vcol.isVisible()) {
>>>>>             continue;
>>>>>         }
>>>>>
>>>>>         if (vcol.getId().equals("id")) {
>>>>>                           AbstractColumn<E> linkcolumnModel=null;
>>>>>             if(vcol.isSort()){
>>>>>                 linkcolumnModel=new SortableIdColumn(new
>>>>> Model(vcol.getTitle()),vcol.getValue());
>>>>>             }else{
>>>>>                 linkcolumnModel=new SortableIdColumn(new
>>>>> Model(vcol.getTitle()));
>>>>>             }
>>>>>
>>>>>             columns.add(linkcolumnModel);
>>>>>
>>>>>         } else if (vcol.isLinkout()) {
>>>>>             LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>>>>>                     .getTitle()), vcol.getValue());
>>>>>   columns.add(linkoutCol);
>>>>>         } else {
>>>>>             //Add normal datacolumn
>>>>>             if(vcol.isSort()){
>>>>>                 columns.add(new PropertyColumn<String>(new
>>>>> Model(vcol.getTitle()),
>>>>>                          vcol.getValue(),vcol.getValue()));
>>>>>           }else{
>>>>>                 columns.add(new PropertyColumn<String>(new
>>>>> Model(vcol.getTitle()),
>>>>>                          vcol.getValue()));
>>>>>       }
>>>>>                     }
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>

Re: DataTable : Setting the Column with from Java ?

Posted by Ashika Umanga Umagiliya <au...@biggjapan.com>.
Thanks for the tips,

I found the solution:

public void populateItem(Item<ICellPopulator<E>> cellitem,
                String id, IModel<E> model) {
               cellitem.add(new 
SimpleAttributeModifier("style","width:"+width+"px"));
}

regards
umanga
nino martinez wael wrote:
> I susspect you should add the attribute modifier to your LinkoutColumn
> telling what css class you want to use.. I would have to see the html aswell
> to help further..
>
> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>
>   
>> Hi nino,
>>
>> To which component I should add an attribute-modifier. In IColumn ,i should
>> add the 'width' to the headers ,i assume.
>> any tips to do this?
>>
>>
>> nino martinez wael wrote:
>>
>>     
>>> use a attribute modifier
>>>
>>>
>>> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>>>
>>>
>>>
>>>       
>>>> Greetings,
>>>>
>>>> For my DataTable ,I create 'IColumn's using data from an XML file.
>>>>
>>>> In the code-snippet below, the 'vcol' instance has information about
>>>> Column-title,bean property field,visible or not..etc.
>>>> Now I want to set the column width using the same way.How can I change
>>>> the
>>>> CSS property from Java ?
>>>> Any tips how I can do this?
>>>>
>>>>
>>>>
>>>> List<IColumn> columns;
>>>> //For each Column in Table
>>>> for (Column vcol : table.getColumns()) {
>>>>          if (!vcol.isVisible()) {
>>>>              continue;
>>>>          }
>>>>
>>>>          if (vcol.getId().equals("id")) {
>>>>                            AbstractColumn<E> linkcolumnModel=null;
>>>>              if(vcol.isSort()){
>>>>                  linkcolumnModel=new SortableIdColumn(new
>>>> Model(vcol.getTitle()),vcol.getValue());
>>>>              }else{
>>>>                  linkcolumnModel=new SortableIdColumn(new
>>>> Model(vcol.getTitle()));
>>>>              }
>>>>
>>>>              columns.add(linkcolumnModel);
>>>>
>>>>          } else if (vcol.isLinkout()) {
>>>>              LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>>>>                      .getTitle()), vcol.getValue());
>>>>    columns.add(linkoutCol);
>>>>          } else {
>>>>              //Add normal datacolumn
>>>>              if(vcol.isSort()){
>>>>                  columns.add(new PropertyColumn<String>(new
>>>> Model(vcol.getTitle()),
>>>>                           vcol.getValue(),vcol.getValue()));
>>>>            }else{
>>>>                  columns.add(new PropertyColumn<String>(new
>>>> Model(vcol.getTitle()),
>>>>                           vcol.getValue()));
>>>>        }
>>>>                      }
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>>     
>
>   


Re: DataTable : Setting the Column with from Java ?

Posted by nino martinez wael <ni...@gmail.com>.
I susspect you should add the attribute modifier to your LinkoutColumn
telling what css class you want to use.. I would have to see the html aswell
to help further..

2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>

> Hi nino,
>
> To which component I should add an attribute-modifier. In IColumn ,i should
> add the 'width' to the headers ,i assume.
> any tips to do this?
>
>
> nino martinez wael wrote:
>
>> use a attribute modifier
>>
>>
>> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>>
>>
>>
>>> Greetings,
>>>
>>> For my DataTable ,I create 'IColumn's using data from an XML file.
>>>
>>> In the code-snippet below, the 'vcol' instance has information about
>>> Column-title,bean property field,visible or not..etc.
>>> Now I want to set the column width using the same way.How can I change
>>> the
>>> CSS property from Java ?
>>> Any tips how I can do this?
>>>
>>>
>>>
>>> List<IColumn> columns;
>>> //For each Column in Table
>>> for (Column vcol : table.getColumns()) {
>>>          if (!vcol.isVisible()) {
>>>              continue;
>>>          }
>>>
>>>          if (vcol.getId().equals("id")) {
>>>                            AbstractColumn<E> linkcolumnModel=null;
>>>              if(vcol.isSort()){
>>>                  linkcolumnModel=new SortableIdColumn(new
>>> Model(vcol.getTitle()),vcol.getValue());
>>>              }else{
>>>                  linkcolumnModel=new SortableIdColumn(new
>>> Model(vcol.getTitle()));
>>>              }
>>>
>>>              columns.add(linkcolumnModel);
>>>
>>>          } else if (vcol.isLinkout()) {
>>>              LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>>>                      .getTitle()), vcol.getValue());
>>>    columns.add(linkoutCol);
>>>          } else {
>>>              //Add normal datacolumn
>>>              if(vcol.isSort()){
>>>                  columns.add(new PropertyColumn<String>(new
>>> Model(vcol.getTitle()),
>>>                           vcol.getValue(),vcol.getValue()));
>>>            }else{
>>>                  columns.add(new PropertyColumn<String>(new
>>> Model(vcol.getTitle()),
>>>                           vcol.getValue()));
>>>        }
>>>                      }
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>

Re: DataTable : Setting the Column with from Java ?

Posted by Ashika Umanga Umagiliya <au...@biggjapan.com>.
Hi nino,

To which component I should add an attribute-modifier. In IColumn ,i 
should add the 'width' to the headers ,i assume.
any tips to do this?

nino martinez wael wrote:
> use a attribute modifier
>
>
> 2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>
>
>   
>> Greetings,
>>
>> For my DataTable ,I create 'IColumn's using data from an XML file.
>>
>> In the code-snippet below, the 'vcol' instance has information about
>> Column-title,bean property field,visible or not..etc.
>> Now I want to set the column width using the same way.How can I change the
>> CSS property from Java ?
>> Any tips how I can do this?
>>
>>
>>
>> List<IColumn> columns;
>> //For each Column in Table
>> for (Column vcol : table.getColumns()) {
>>           if (!vcol.isVisible()) {
>>               continue;
>>           }
>>
>>           if (vcol.getId().equals("id")) {
>>                             AbstractColumn<E> linkcolumnModel=null;
>>               if(vcol.isSort()){
>>                   linkcolumnModel=new SortableIdColumn(new
>> Model(vcol.getTitle()),vcol.getValue());
>>               }else{
>>                   linkcolumnModel=new SortableIdColumn(new
>> Model(vcol.getTitle()));
>>               }
>>
>>               columns.add(linkcolumnModel);
>>
>>           } else if (vcol.isLinkout()) {
>>               LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>>                       .getTitle()), vcol.getValue());
>>     columns.add(linkoutCol);
>>           } else {
>>               //Add normal datacolumn
>>               if(vcol.isSort()){
>>                   columns.add(new PropertyColumn<String>(new
>> Model(vcol.getTitle()),
>>                            vcol.getValue(),vcol.getValue()));
>>             }else{
>>                   columns.add(new PropertyColumn<String>(new
>> Model(vcol.getTitle()),
>>                            vcol.getValue()));
>>         }
>>                       }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   


Re: DataTable : Setting the Column with from Java ?

Posted by nino martinez wael <ni...@gmail.com>.
use a attribute modifier


2010/2/4 Ashika Umanga Umagiliya <au...@biggjapan.com>

> Greetings,
>
> For my DataTable ,I create 'IColumn's using data from an XML file.
>
> In the code-snippet below, the 'vcol' instance has information about
> Column-title,bean property field,visible or not..etc.
> Now I want to set the column width using the same way.How can I change the
> CSS property from Java ?
> Any tips how I can do this?
>
>
>
> List<IColumn> columns;
> //For each Column in Table
> for (Column vcol : table.getColumns()) {
>           if (!vcol.isVisible()) {
>               continue;
>           }
>
>           if (vcol.getId().equals("id")) {
>                             AbstractColumn<E> linkcolumnModel=null;
>               if(vcol.isSort()){
>                   linkcolumnModel=new SortableIdColumn(new
> Model(vcol.getTitle()),vcol.getValue());
>               }else{
>                   linkcolumnModel=new SortableIdColumn(new
> Model(vcol.getTitle()));
>               }
>
>               columns.add(linkcolumnModel);
>
>           } else if (vcol.isLinkout()) {
>               LinkoutColumn linkoutCol = new LinkoutColumn(new Model(vcol
>                       .getTitle()), vcol.getValue());
>     columns.add(linkoutCol);
>           } else {
>               //Add normal datacolumn
>               if(vcol.isSort()){
>                   columns.add(new PropertyColumn<String>(new
> Model(vcol.getTitle()),
>                            vcol.getValue(),vcol.getValue()));
>             }else{
>                   columns.add(new PropertyColumn<String>(new
> Model(vcol.getTitle()),
>                            vcol.getValue()));
>         }
>                       }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>