1. #1
    Ext User
    Join Date
    Mar 2010
    Posts
    1
    Vote Rating
    0
    namrata.rane is on a distinguished road

      0  

    Default Using Grid Panel : Spring with extjs and JSON

    Using Grid Panel : Spring with extjs and JSON


    I am an extjs newbie and I want to use data returned from a Spring controller in ext-js code to populate a GridPanel. Here is what happens :
    - A page with a form gets submitted
    - Spring MVC controller gets invoked
    - the controller calls the service layer that returns a list
    - this list needs to be displayed on UI using a extjs GridPanel
    - The list is now apart of the model returned from controller

    The question I have is how to access the data from the Spring model object in the ext-js code to define a GridPanel ?

    Here is how I define the GridPanel


    Code:
        
            var myGrid = new Ext.grid.GridPanel({
            store: myStore,
            renderTo: 'myDiv',
            columns: [
                {header: 'UUID', width: 300, sortable: true, dataIndex: 'uniqueId'}
            ],
            stripeRows: true,
            height:350,
            width:350,
            frame:true,
            title: 'List of Unique IDs'
        });
    I understand that the GridPanel would need a datastore. Note that this data store has all the data it needs on the client side, so there is no URL.

    I tried to get the list data in JSON format in a hidden element [listOfUniqueIDs] in the JSP and use it in the datastore like this:

    Code:
        
    var myStore = new Ext.data.JsonStore({
           fields: [
                'uniqueId', 'createdBy'
            ]
            data : Ext.get('listOfUniqueIDs').getAttribute('value')
    });
    But it doesn't seem to get the data and the grid doesn't display anything.


    Any ideas on how to get this data displayed ?

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    try adding autoLoad : true to your data store config

Thread Participants: 1