Hybrid View
-
28 Sep 2008 8:00 AM #1
how to move the grid's row up and down?
how to move the grid's row up and down?
I have two button to control the grid's rows, one is move up, and the other is move down,
I want to move the selected row move up/down to the be/next row, when i click the move button,
I find the api document, but no found any methods about that,
pleast give me some help, thanks!
-
28 Sep 2008 8:18 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
Read the API docs for RowSelectionModel:
Code:grid.getSelectionModel().selectPrevious()/selectNext()
-
28 Sep 2008 8:33 AM #3
maybe i am no say the question clear,
I want to move the seleted the row move up/down, let me draw
before move up
--------------------
row1
--------------------
row2 (this selected row)
--------------------
after move
--------------------
row2 (be move up to row1)
--------------------
row1
--------------------

-
28 Sep 2008 9:01 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
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); }
-
28 Sep 2008 9:31 AM #5
-
11 Jun 2009 9:59 PM #6
it would be nice to see the code to update the db as well..

In my case, i have a 'position' attribute in db i need to update it each time a user clicks on move up or move down buttons

-
26 Dec 2010 10:40 PM #7
-
26 Dec 2010 10:58 PM #8
-
22 Sep 2011 5:40 AM #9
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
-
15 Jan 2013 1:44 AM #10


Reply With Quote