Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default Grid's CellSelectionModel returns incorrect values in case of LiveGridView 2.2.5.

    Grid's CellSelectionModel returns incorrect values in case of LiveGridView 2.2.5.


    Hi, guys.

    We're using LiveGridView with a capability to remove rows upon click of a button.
    Unfortunately, grid.getSelectionModel().getSelectedItems(); returns wrong model data objects.
    Is there a way to fix it or is there an alternative way to get the model data object actually selected?

    Thank you in advance.

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    Please note, that we can't remove from the store as it acts as cache for currently visible rows.
    Instead, we use the model data object to remove it from original data source and reload.

  3. #3
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Quote Originally Posted by atrubka View Post
    Please note, that we can't remove from the store as it acts as cache for currently visible rows.
    Instead, we use the model data object to remove it from original data source and reload.
    Can you please explain a little more what you mean with this? If you reload the hole store after deleting, there should not be any model selected anymore.

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    1. Load a store for LiveGridView. Let's say total is 1000 and we only keep 100.
    2. Scroll down to force loading another 100 of the entire 1000 set.
    3. Select an item by clicking mouse button.
    4. We have a button that does something like this (pseudo-code):
    originalSet.removeItems(grid.getSelectionModel().getSelectedItems());
    store.getLoader().load();
    5. As a result store is supposed to be populated with correct set of records after removal of selected items.

    We expect selected items to reflect what's actually been selected, however they are different and only match actual selection when view is in the top scroll position. So our removeItems() method can't work correctly because wrong items are passed there.

  5. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    I will move this thread to the bugs forum for further investigation. The selectionmodel might be bound to the wrong store.

  6. #6
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    If you can think of any workaround I would be glad to implement it in our application.

  7. #7
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    CORRECTION:

    It's GridSelectionModel (not CellSelectionModel). It's harder to fix than CellSelectionModel.

  8. #8
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    One of the suspects is here. Since it goes by model (M sel) rather than by index (e.getRowIndex()) it receives wrong index that corresponds to an actually selected row counted from the top of the grid. So at least 2 adjustments would need to be applied. For cache window and for scrolling within the cache.
    Looks like this is not the only place, where selection is changed though.

    Code:
        if (selectionMode == SelectionMode.MULTI) {
          M sel = listStore.getAt(e.getRowIndex());
          if (e.isControlKey() && isSelected(sel)) {
            doDeselect(Arrays.asList(sel), false);
          } else if (e.isControlKey()) {
            doSelect(Arrays.asList(sel), true, false);
            grid.getView().focusCell(e.getRowIndex(), e.getColIndex(), false);
          } else if (isSelected(sel) && !e.isShiftKey() && !e.isControlKey() && selected.size() > 1) {
            doSelect(Arrays.asList(sel), false, false);
            grid.getView().focusCell(e.getRowIndex(), e.getColIndex(), false);
          }
        }

  9. #9
    Sencha User
    Join Date
    Nov 2010
    Posts
    90
    Vote Rating
    0
    atrubka is on a distinguished road

      0  

    Default


    For instance this is how index is handled in the LiveGridEvent:

    Code:
      public M getModel() {
        if (getRowIndex() != -1) {
          model = getGrid().getStore().getAt(getRowIndex() + viewIndex - liveStoreOffset);
        }
        return model;
      }
    BTW, this calculation is not always working either...

Thread Participants: 1