1. #1
    Ext User
    Join Date
    Oct 2009
    Posts
    3
    Vote Rating
    0
    auction123 is on a distinguished road

      0  

    Default Getting Row Index of GridPanel

    Getting Row Index of GridPanel


    I have a grid panel that i need to manually select the index of.
    When scrolling, the id's of the items change so that does not work.
    I have tried:

    GridPanelExports.getSelectionModel().getSelected()

    But that only returns an object with an id, but the id is NOT the index.

    How would i go about selecting a row in a grid panel that has no unique fields?
    Last edited by auction123; 26 Oct 2009 at 8:08 AM. Reason: Typo

  2. #2
    Ext User
    Join Date
    Oct 2009
    Posts
    4
    Vote Rating
    0
    lyle is on a distinguished road

      0  

    Post


    Can you try using the rowselect, beforerowselect or selectionChange events on the grid? They all return a row index. One way is to stuff that value into a hidden form field each time it changes, so it is always available.

    In the rowselect listener:

    function(select,rowNum,rec) {
    Ext.getCmp('theHiddenField').setValue(rowNum);
    }

    Then when you want the currently selected row call:
    curRow = Ext.getCmp('theHiddenField').getValue;

    Hope that helps.

  3. #3
    Ext User
    Join Date
    Oct 2009
    Posts
    3
    Vote Rating
    0
    auction123 is on a distinguished road

      0  

    Default


    I don't think thats quite it.

    If it can be stored in a hidden field, how does the hidden field get the value?

    I just need a way to get index... the number of the selected row (not the id of the item).

    GridPanel.getSelectionModel().getSelected()
    does not work.

    It just seems like theres no way of doing this. But it is possible for some reason to do the opposite:
    GridPanel.getSelectionModel().selectRow( INDEX )

    Like i said, just trying to get the index (the row number, first, second) somehow.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    What does getSelected return? (There's no getSelectedRow, you just invented that)

  5. #5
    Ext User
    Join Date
    Oct 2009
    Posts
    4
    Vote Rating
    0
    lyle is on a distinguished road

      0  

    Default


    Create an event listener on your grid -- for the event "rowselect"
    Put the following function in that event listener.

    function(select,rowNum,rec) {
    Ext.getCmp('theHiddenField').setValue(rowNum);
    }


    The event for the grid -- rowselect returns three items, the the selectionmode, the row number and the record. In my example above the row number = rowNum.

    I set it to a hidden field = theHiddenField. That's how the theHiddenField gets the row number value.

  6. #6
    Ext User
    Join Date
    Oct 2009
    Posts
    4
    Vote Rating
    0
    lyle is on a distinguished road

      0  

    Default


    Here's another thought, something I ran across today. Doesn't work for me, but maybe it will for you. This is version 2.0 so please lookup or adjust accordingly if you are using version 3.

    From EXTJS 2.2.1 API Documentation
    // This is a typical column config with the first column providing row numbers
    var colModel = new Ext.grid.ColumnModel([
    new Ext.grid.RowNumberer(),
    {header: "Name", width: 80, sortable: true},
    {header: "Code", width: 50, sortable: true},
    {header: "Description", width: 200, sortable: true}
    ]);

  7. #7
    Ext JS Premium Member
    Join Date
    Jun 2008
    Posts
    6
    Vote Rating
    0
    srivaspu is on a distinguished road

      0  

    Default Use this ...

    Use this ...


    Code:
    Ext.grid.RowSelectionModel.override ({
        getSelectedIndex : function(){
            return this.grid.store.indexOf( this.selections.itemAt(0) );
        }
    });
    then you can use the function getSelectedIndex(), e.g.,
    GridPanelExports.getSelectionModel().getSelectedIndex()

  8. #8
    Ext User
    Join Date
    Apr 2009
    Posts
    31
    Vote Rating
    0
    riya_phoenix is on a distinguished road

      0  

  9. #9
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,669
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    Code:
    Ext.grid.RowSelectionModel.override ({
        getSelectedIndex : function(){
            return this.grid.store.indexOf( this.selections.itemAt(0) );
        }
    });
    +1 feature request

  10. #10
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    288
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    +1 feature request

    Stju

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