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 <steve.ey...@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 <vjeran.marci...@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-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>

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

Reply via email to