You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Steve Eynon <st...@googlemail.com> on 2011/05/25 15:29:06 UTC
Re: Grid disable sorting mixin
Hi,
It works for me!
Although I found I needed to use the @MixinAfter class annotation for
I was adding extra columns.
Steve.
2011/2/26 Vjeran Marcinko <vj...@email.t-com.hr>:
> Hello all,
>
> I developed simple mixin that disables sorting for any Grid. I didn't test
> it extensively, but it seems to work, so if anyone is interested here it is:
>
> import org.apache.tapestry5.annotations.InjectContainer;
> import org.apache.tapestry5.beaneditor.BeanModel;
> import org.apache.tapestry5.beaneditor.PropertyModel;
> import org.apache.tapestry5.corelib.components.Grid;
>
> import java.util.List;
>
>
> public class GridSortingDisabled {
> @InjectContainer
> private Grid grid;
>
> private void setupRender() {
> BeanModel model = grid.getDataModel();
> List<String> propertyNames = model.getPropertyNames();
> for (String propName : propertyNames) {
> PropertyModel propModel = model.get(propName);
> propModel.sortable(false);
> }
> }
> }
>
>
> Cheers,
> Vjeran
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Grid disable sorting mixin
Posted by Steve Eynon <st...@alienfactory.co.uk>.
There's a gotcha with the Mixin that can generate an Exception if used
on a Grid with no data. Here's the complete working Mixin;
@MixinAfter
public class DisableGridSorting {
@InjectContainer
private Grid grid;
void setupRender() {
if (grid.getDataSource().getAvailableRows() == 0)
return;
BeanModel<?> model = grid.getDataModel();
List<String> propertyNames = model.getPropertyNames();
for (String propName : propertyNames) {
PropertyModel propModel = model.get(propName);
propModel.sortable(false);
}
}
}
Thought I'd resurrect (and contribute to) this thread as I find the
Mixin really handy.
Steve.
On 25 May 2011 21:29, Steve Eynon <st...@googlemail.com> wrote:
> Hi,
>
> It works for me!
>
> Although I found I needed to use the @MixinAfter class annotation for
> I was adding extra columns.
>
> Steve.
>
>
> 2011/2/26 Vjeran Marcinko <vj...@email.t-com.hr>:
>> Hello all,
>>
>> I developed simple mixin that disables sorting for any Grid. I didn't test
>> it extensively, but it seems to work, so if anyone is interested here it is:
>>
>> import org.apache.tapestry5.annotations.InjectContainer;
>> import org.apache.tapestry5.beaneditor.BeanModel;
>> import org.apache.tapestry5.beaneditor.PropertyModel;
>> import org.apache.tapestry5.corelib.components.Grid;
>>
>> import java.util.List;
>>
>>
>> public class GridSortingDisabled {
>> @InjectContainer
>> private Grid grid;
>>
>> private void setupRender() {
>> BeanModel model = grid.getDataModel();
>> List<String> propertyNames = model.getPropertyNames();
>> for (String propName : propertyNames) {
>> PropertyModel propModel = model.get(propName);
>> propModel.sortable(false);
>> }
>> }
>> }
>>
>>
>> Cheers,
>> Vjeran
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org