1. #11
    Sencha User jaisonjames's Avatar
    Join Date
    Jul 2010
    Posts
    67
    Vote Rating
    1
    jaisonjames is on a distinguished road

      0  

    Default


    Great!!! Working fine

    Thanks you dear Condor

    Quote Originally Posted by Condor View Post
    Code:
    {
      icon: '../image/reportui/icon-grid-moveup.png',
      tooltip:'Move to Up Selected Row',
      handler: function(){
        moveSelectedRow(componentsconfig, -1);
      }
    },

  2. #12
    Sencha User
    Join Date
    Nov 2010
    Location
    USA
    Posts
    111
    Vote Rating
    0
    aramaki is on a distinguished road

      0  

    Default


    thx, Condor, but after moving and then save changes (editorgrid) I see a row duplicates, how to fix it, I cann`t imaginate

  3. #13
    Sencha User
    Join Date
    Nov 2010
    Location
    USA
    Posts
    111
    Vote Rating
    0
    aramaki is on a distinguished road

      0  

    Default


    sorry) already fix
    PHP Code:
              var purgeFromRemoved App.in_array(record,this.store.removed) ? false true;

                
    this.store.remove(record);
                
    this.store.insert(indexrecord);

                
    // purge record from removed
                
    if(purgeFromRemoved){
                    var 
    this.store.removed.indexOf(record);
                    if(
    != -1this.store.removed.splice(i,1);
                } 

  4. #14
    Sencha User
    Join Date
    Sep 2011
    Posts
    1
    Vote Rating
    0
    jophin is on a distinguished road

      0  

    Default


    Hi,
    I am a beginner in ext js. i am using Ext.NET.
    I am not sure howw to make this work for me.
    Can anyone help?
    Regads
    Jophin

  5. #15
    Sencha User
    Join Date
    Nov 2012
    Posts
    3
    Vote Rating
    0
    winnyladi is on a distinguished road

      0  

    Default


    Hi,
    The selected row is moving with this code. Can you also explain, while moving up/down scrollbar should
    also move when needed.

    Quote Originally Posted by Condor View Post
    OK, that's something entirely different.

    Try:
    Code:
    function moveSelectedRow(grid, direction) {
        var record = grid.getSelectionModel().getSelected();
        if (!record) {
            return;
        }
        var index = grid.getStore().indexOf(record);
        if (direction < 0) {
            index--;
            if (index < 0) {
                return;
            }
        } else {
            index++;
            if (index >= grid.getStore().getCount()) {
                return;
            }
        }
        grid.getStore().remove(record);
        grid.getStore().insert(index, record);
        grid.getSelectionModel().selectRow(index, true);
    }

  6. #16
    Sencha User
    Join Date
    Jan 2012
    Posts
    6
    Vote Rating
    0
    RandellB is on a distinguished road

      0  

    Default


    I was working on problem like this and thought I'd mention a little shortcut I found. In our code we have to move one or multiple rows at once but we only have to move then by one position at a time. I found that it was easier to move one row "out of the way" instead of moving each row in the selected group.

    For example, assuming a grid with 7 rows and the user wants to move rows 2, 3 and 4 down by one position. Instead of looping through the selected group of rows and moving them one at a time, you can move row 5 to position 2 and get the same effect as moving the selected group of rows.

  7. #17
    Sencha User
    Join Date
    Sep 2013
    Location
    Brisbane, Australia
    Posts
    14
    Vote Rating
    0
    Sohil.Patel is on a distinguished road

      0  

    Default getSelected() Method is not present any more

    getSelected() Method is not present any more


    I am getting error saying getSelected() method is not present. What changes to be done in this code to move grid's row up and down working?

    var record = grid.getSelectionModel().getSelected();
    if (!record) {
    return;
    }
    var index = grid.getStore().indexOf(record);
    if (direction < 0) {
    index--;
    if (index < 0) {
    return;
    }
    } else {
    index++;
    if (index >= grid.getStore().getCount()) {
    return;
    }
    }
    grid.getStore().remove(record);
    grid.getStore().insert(index, record);
    grid.getSelectionModel().selectRow(index, true);