Hybrid View

  1. #1
    Sencha User enotsl's Avatar
    Join Date
    Jul 2007
    Posts
    42
    Vote Rating
    0
    enotsl is on a distinguished road

      0  

    Default 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!

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    87
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Read the API docs for RowSelectionModel:

    Code:
    grid.getSelectionModel().selectPrevious()/selectNext()

  3. #3
    Sencha User enotsl's Avatar
    Join Date
    Jul 2007
    Posts
    42
    Vote Rating
    0
    enotsl is on a distinguished road

      0  

    Default


    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
    --------------------


  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    87
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      1  

    Default


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

  5. #5
    Sencha User enotsl's Avatar
    Join Date
    Jul 2007
    Posts
    42
    Vote Rating
    0
    enotsl is on a distinguished road

      0  

    Default


    oh, hoho,

    it's working prefect, thanks!

  6. #6
    Ext User
    Join Date
    May 2009
    Posts
    1
    Vote Rating
    0
    FunkyDude is on a distinguished road

      0  

    Default


    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

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

      0  

    Default


    I think this will help me, but how it will implement in a array 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);
    }

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    87
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Quote Originally Posted by jaisonjames View Post
    I think this will help me, but how it will implement in a array grid?
    Strange question... the code is independent of the reader that is used by the store.

    ps. 'direction' should be -1 or +1.

  9. #9
    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

  10. #10
    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);
    }

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi