1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    6
    Vote Rating
    0
    zalol is on a distinguished road

      0  

    Default Answered: How to get data from GridPanel

    Answered: How to get data from GridPanel


    Hi All,


    I am trying to to get the data from GridPanel. I tried to use grid.getSelections(), but FireBug is complaining that it is not a function.

    I am new to EXTJS so if anyone knows how to solve this, please help.


    Thanks.

    Zalol.

    Update:
    Apologies. Looks like I made a post in EXTJS 4. Can you please move it from here. I am using EXTJS 3.4
    Last edited by zalol; 17 Aug 2011 at 5:35 PM. Reason: Wrong section

  2. if you only want an array of all data you can use
    Code:
    grid.getStore().data.items
    http://docs.sencha.com/ext-js/4-0/#/...-property-data

    if you want to search for a specific record(s), you can usee
    Code:
    grid.getStore().data.filter(propertyKey, valueToSearchFor);
    http://docs.sencha.com/ext-js/4-0/#/api/Ext.util.MixedCollection-method-filter

    h
    ope that helps.

  3. #2
    Sencha User
    Join Date
    Sep 2009
    Posts
    85
    Answers
    8
    Vote Rating
    -1
    raz0r1 is an unknown quantity at this point

      0  

    Default


    You have to specify a little:
    do you want to get the selected records or do you want to get all records?

    If you want to get the selected records, use:

    Code:
    var selModel = panel.getSelectionModel();
    var selectedRecords = selModel.getSelection();
    var selectionCount = selModel.getCount();
    for(var i =0;i<selectionCount;i++) {
    console.log(selectedRecords[i]);
    }
    This logs the underlying storerecord of the selected row to your firebug console.

  4. #3
    Sencha User
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    53
    Answers
    2
    Vote Rating
    2
    HTK is on a distinguished road

      0  

    Default


    This is really a bit general, but I maybe this helps:
    Code:
    grid.getView().getSelectionModel().getSelection()[0]
    grid.getView().getSelectedRecords()
    I guess what you are searching is in the view class.

  5. #4
    Sencha User
    Join Date
    Jul 2011
    Posts
    6
    Vote Rating
    0
    zalol is on a distinguished road

      0  

    Default


    Thanks for the reply guys.


    Sorry for not being specific on my question. What I am looking to do is to get all the records from the Grid.

  6. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,506
    Answers
    528
    Vote Rating
    288
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Sorry for not being specific on my question. What I am looking to do is to get all the records from the Grid.
    So you want all of them, not just the selected ones? The records all live in a store. Essentially the store is 'all the records'. You haven't said exactly what form you want the records in or how you intend to use them. You have several methods available to you on the store, including each() for iterating over them.

    Code:
    grid.getStore().each(function(record) {
        ...
    });

  7. #6
    Sencha User
    Join Date
    Sep 2009
    Posts
    85
    Answers
    8
    Vote Rating
    -1
    raz0r1 is an unknown quantity at this point

      0  

    Default


    if you only want an array of all data you can use
    Code:
    grid.getStore().data.items
    http://docs.sencha.com/ext-js/4-0/#/...-property-data

    if you want to search for a specific record(s), you can usee
    Code:
    grid.getStore().data.filter(propertyKey, valueToSearchFor);
    http://docs.sencha.com/ext-js/4-0/#/api/Ext.util.MixedCollection-method-filter

    h
    ope that helps.

  8. #7
    Ext JS Premium Member
    Join Date
    Apr 2008
    Location
    Oslo
    Posts
    64
    Answers
    2
    Vote Rating
    0
    mikhailt is on a distinguished road

      0  

    Default


    Depends on your proxy settings.
    In case of local memory proxy I use
    grid.getStore().getProxy().data

    In case of remote proxy you need to retrieve date remotely I guess.

  9. #8
    Sencha User
    Join Date
    Jul 2011
    Posts
    17
    Vote Rating
    -1
    Ixtinkt is an unknown quantity at this point

      0  

    Default


    ExtJs 4.0.2a


    var element_id; // view id of record.
    grid.getStore().data.map[element_id].data;