Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: how to move the grid's row up and down?

  1. #11
    Sencha User jaisonjames's Avatar
    Join Date
    Jul 2010
    Posts
    67
    Vote Rating
    1
      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
      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
      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
      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
      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
      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
      0  

    Default 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);

  8. #18
    Sencha User
    Join Date
    May 2011
    Posts
    10
    Vote Rating
    0
      0  

    Default

    hi,
    how can I revert it to same position after moving up and/or down. I have another button revert.

  9. #19
    Sencha User
    Join Date
    Oct 2016
    Posts
    1
    Vote Rating
    0
      0  

    Default where i should call this function in kendo grid

    HI Can you help me out where i should call this function in kendo grid

    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);
    }

  10. #20
    Sencha User
    Join Date
    Aug 2015
    Posts
    4
    Vote Rating
    0
      0  

    Default

    This code working good in ungrouped list. But i used this code in grouped list. when i move the selected list down, it goes down. but when i move the list up, it goes down also. How's the possible solution for the selected list to move up and down in their grouping?

    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);
    }

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •