Search code examples
gxt

Disable a EditorGrid row when a model attribute has been updated


Here's my request :

I have an EditorGrid which renders some rows based on its associated ListStore.

The ListStore has a collection of instances of my model which has an attribute called "markeAsDeleted" which is updated elsewhere in the UI.

My question is :

How is-it possible to change the rendering of the corresponding row to turn it 'disabled' when my 'markAsDeleted' attribute is 'true' ?

What's I'm expecting is a kind of a rendrer to add to my EditorGrid instance which updates the row as the model attribute is updated.

Thanks


Solution

  • Hiding the column with filtering would be your best best.

    If you set store.setMonitoChanges(true); then I believe it will reconise when anything changes that model in the store and fire an storeUpdate from there you could re-Apply your filter (if it doesnt do that automatically anyway);

    example

    store.addStoreListener(new StoreListener<BaseModelData>() {
      public void storeUpdate(StoreEvent<M> se) {
          store.applyFilters("");
      }
    })
    

    edit: After reading the comments on another answer I notice you are using a Grid filter to filter the columns you could just as easily use addFilter on a store.

    example

    store.addFilter(new StoreFilter<BaseModelData>() {
       public boolean select(Store<T> store, T parent, T item, String property) {
          return !item.get("markAsDeleted");
       }
    });