1. #1
    Sencha User
    Join Date
    Oct 2008
    Posts
    39
    Vote Rating
    0
    iBeb is on a distinguished road

      0  

    Default deselectRow(index) & getSelectionModel() index

    deselectRow(index) & getSelectionModel() index


    Hi there,

    I'm experiencing a issue with getSelectionModel() and deselectRow().
    I have a grid with a RowSelectionModel. There's one button to delete selected rows.
    But before to delete the row, I have to check is one field in record.data is not equal to a certain value. Regarding this, I allow or not to delete the row, and deselect the row if not allowed.

    PHP Code:
        ,delRoom:function(p){
            
    p.getSelectionModel().each(function(item,index){
                if(
    item.data.parent_id==1||item.data.r_room_id==1){
                    
    Ext.ux.Toast.msg(__('shared.popup.avertissement'),__('travel.popup.roomError'));
                    
    p.getSelectionModel().deselectRow(index);
                }
            },
    this);
            return 
    true;
        } 
    The thing is getSelectionModel().each() returns the index of the row inside the selection, and to deselect a row you need the index of the row inside the grid

    So as you can see, my function doesn't work, because I don't use the good index to deselect a row.
    I don't know how to make the two indexes match.
    Which method could I use from Ext.grid.GridPanel or Ext.grid.RowSelectionModel to make it work?

    Thanx in advance,

    _bertrand

  2. #2
    Ext User
    Join Date
    Oct 2008
    Posts
    41
    Vote Rating
    0
    Spring is on a distinguished road

      0  

    Default


    You can define the row index from store. In this case it will look like:


    Code:
     
    p.getSelectionModel().deselectRow(p.getStore().indexOf(item));

Thread Participants: 1