1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    yesakmac is on a distinguished road

      0  

    Default Unanswered: Datastore to java variable

    Unanswered: Datastore to java variable


    I'm trying to place records from a datastore into a javascript variable on my page. I have it writing to a grid panel and the information is coming across so I know it's there, I just don't know how to access the datastore records individually. After that I need to and pass them back to my html page. I'm flying solo here at work, as extjs is completely new to me. I've looked through a good portion of the documentation on both datastores and gridpanels, as well as the forums, and I have read 2 schools of thought, 1 is that I should load the data from the model directly (which I'm not sure if that's possible considering the actual data is in the store) and 2 I should do it like I am doing it currently.

    The ajax request will always just pull back 1 record.

    Code:
    Ext.onReady(function(){
    
    var params = Ext.urlDecode(location.search.substring(1));
    var oms_premise = params.OMS_Premise
        
    //DEFINE MODEL
     Ext.define('Customer', {
         extend: 'Ext.data.Model',
         fields: [
                {name: 'ACCOUNT_NUM'},
                { name: 'LOCATION' },
                { name: 'METER_NUM' },
                { name: 'NAME' },
                { name: 'PHONE' },
                { name: 'XFMR' }
                ]
            });
     //GET DATA
     var myStore = Ext.create('Ext.data.Store', {
         model: 'Customer',
         proxy: {
             type: 'ajax',
             url: 'http://omsdev/omsportal/Application/Framework/getCustByOMSPremise.aspx?oms_premise=' + oms_premise,
                reader:
                    {
                     root: 'Customer Info',
                     totalProperty: 'totalCount'
                    }
                   },    
            autoLoad: true
        });    
        //LOAD DATA
     myStore.load();
        // DRAW GRID
        var grid;
        grid  = new Ext.grid.GridPanel({
            store: myStore,
            columns: [
                 { header: 'NAME', width: 150, dataIndex: 'NAME' },
                 { header: 'LOCATION', width: 300, dataIndex: 'LOCATION' },
                { header: 'METER_NUM', width: 100, dataIndex: 'METER_NUM' },
               { header: 'PHONE', width: 90, dataIndex: 'PHONE' },
                  { header: 'ACCOUNT_NUM', width: 150, dataIndex: 'ACCOUNT_NUM' }
    //            {header: 'OUTAGE MINUTES', width: 120, sortable: true, dataIndex: 'OUT_MINUTES'},
    //            {header: 'CDTS', width: 90, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y H:i:s'), dataIndex: 'CDTS'},
    //            {header: 'OFFTIME', width: 90, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y H:i:s'), dataIndex: 'OFFTIME'},
    //            {header: 'CAUSE CODE', width: 150, sortable: true, dataIndex: 'CAUSE_CODE',renderer:causeDecode},
    //            {header: 'WEATHER CODE', width: 90, sortable: true, dataIndex: 'WEATHER_CODE'},
    //            {header: 'COMPLETION REMARKS', width: 200, sortable: true, dataIndex: 'COMPLETION_REMARKS'}
            ],
            renderTo: 'CustomerGrid'
            //       
        });
     });
    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You are letting the store load it so how you are doing it is fine.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread