1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    32
    Vote Rating
    0
    torsten.t is on a distinguished road

      0  

    Default Answered: Deselect a grid cell when adding a new row (remove blue background)

    Answered: Deselect a grid cell when adding a new row (remove blue background)


    When adding a new row the former edited cell is still marked active.

    Steps to reproduce:
    I edit the first cell in row number 3 of a grid panel.
    Now I add a new record and start editing the first cell of this record. This works

    But the former edited cell in row 3 gets the blue background (x-grid-cell-selected).
    How can I remove the blue background from the cell in row 3 ?
    As the first cell of the new row is edited the cell in row 3 should not be marked active.

    I have a Cellediting Model and am trying to deselect the marked cell in the handler of the Add-Button
    Code:
      plugins: [cellEditing],
      dockedItems: [{
        xtype: 'toolbar',
        items: [{
          iconCls: 'icon-add',
          text: 'Add',
          itemId: 'bt_add',
          handler: function () {
            var grid = this.up('panel');
            grid.getSelectionModel().deselectAll();                // not working, now cell in row 2 is marked ???
            grid.getSelectionModel().getLastSelected().deselect;   // not working, cell in row 3 still marked
            var rec = new GridModel({
            });
            rec.setDirty();
            grid.getStore().insert(0, rec);
            //grid.getStore().first().setActive();        
            grid.getView().select(rec);                          // not working, cell in row 3 still marked
            cellEditing.startEdit(0, 0);
            grid.down('#bt_add').disable();
          }

  2. try to refresh the view

    me.getView().refresh();

  3. #2
    Sencha User Jad's Avatar
    Join Date
    Feb 2012
    Location
    annecy france
    Posts
    61
    Vote Rating
    0
    Answers
    7
    Jad is on a distinguished road

      0  

    Default


    try to refresh the view

    me.getView().refresh();

  4. #3
    Sencha User
    Join Date
    Dec 2007
    Posts
    32
    Vote Rating
    0
    torsten.t is on a distinguished road

      0  

    Default


    Thanks Jad, Excellent.

    It is a good idea to put the refresh at the end. The following is working

    Code:
      plugins: [cellEditing],
      dockedItems: [{
        xtype: 'toolbar',
        items: [{
          iconCls: 'icon-add',
          text: 'Add',
          itemId: 'bt_add',
          handler: function () {
            var grid = this.up('panel');
            var rec = new GridModel({
            });
            rec.setDirty();
            grid.getStore().insert(0, rec);
            grid.getView().select(rec);
            cellEditing.startEdit(0, 0);
            grid.getView().refresh();        // This line is the important one. Thanks Jad
            grid.down('#bt_add').disable();
          }

  5. #4
    Sencha User Jad's Avatar
    Join Date
    Feb 2012
    Location
    annecy france
    Posts
    61
    Vote Rating
    0
    Answers
    7
    Jad is on a distinguished road

      0  

    Default


    you're welcome