Results 1 to 2 of 2

Thread: Datastore to java variable

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Answers
    3887
    Vote Rating
    1297
      0  

    Default

    You are letting the store load it so how you are doing it is fine.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •