1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    10
    Vote Rating
    0
    CaryLi is on a distinguished road

      0  

    Default how to deal the store for a Grid.

    how to deal the store for a Grid.


    hi All,

    I am new to ext4.x, and currently I use the MVC structure of extjs ,and I used the associations in the model, then the issue is how to retrieve the associations data by using store?

    Model:
    Ext.define('CAS.reportingAdmin.model.Report', {

    fields: [
    'reportName', 'enabled', 'executable', 'description', 'configured',
    'clientMetadata', 'displayGroupCode',
    'reportName',
    'inconsistentWithSourceSystem', 'reportId',
    'sourceSystemId'
    ],
    associations: [
    {
    type: 'hasMany',
    model: 'CAS.reportingAdmin.model.ReportParameter',
    name: 'reportParameters',
    instanceName: 'reportParameter'
    }

    proxy: Ext.create('CAS.reportingAdminTest.proxies.ReportFileAjaxProxy')
    }

    STORE:
    Ext.define('CAS.reportingAdmin.store.Reports', {
    extend: 'Ext.data.Store',
    requires: 'CAS.reportingAdmin.model.Report',
    autoLoad: true,
    autoSync: true,


    constructor: function (cfg) {
    cfg = cfg || {};
    return this.callParent([
    Ext.apply({


    model: "CAS.reportingAdmin.model.Report",
    proxy: this.reportsProxy,
    listeners: {
    'load': function (store, records, options) {
    console.info('Start reportStore loaded');


    console.info('End reportStore loaded');
    }
    }
    }, cfg)]);
    }
    });



    then VIEW:
    Ext.define('CAS.reportingAdmin.view.parameter.ReportParameter', {
    extend : 'Ext.grid.Panel',
    alias : 'widget.reportparameter',
    title : 'Parameter List',

    initComponent : function() {
    store : 'Reports', columns : [{
    text : "Name",
    flex : 1,
    dataIndex :'name',
    groupable : false


    }, {
    text : "Hidden",
    flex : 1,
    dataIndex : 'required',
    groupable : false


    }, {
    text : "Enabled",
    flex : 1,
    dataIndex : 'reportParameter.',
    groupable : false


    },
    }}

    so in the view level , I can get the report store correctly, but that's not I want to display , actually I only want to display the reportParameter (which is the association part of report), so I need to parse the retrieved store and only get the parameter content of the store data and then display to the page, so how to this action?

    thanks in advance.
    Regards,
    Cary

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Vote Rating
    814
    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


    Sounds like you aren't wanting to use associations. You could use mapping config in the field of the model to grab nested data and make it available to the top level record.
    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.

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    10
    Vote Rating
    0
    CaryLi is on a distinguished road

      0  

    Default


    thanks, you r correct, if don't want to use association, mapping config in the model can be a good a good approach.

    and here is my current solution, maybe help for new comer:
    in this situation , we can parse store

    var index = this.getStore().findExact('name',paraName);
    var record= this.getStore().getAt(index);

    and many ways to parse store, and this is just one of them.

    thanks

Thread Participants: 1

Tags for this Thread