1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    3
    Vote Rating
    0
    FOONTIK is on a distinguished road

      0  

    Default not hard coded property fields of Ext.data.XmlReader ?

    not hard coded property fields of Ext.data.XmlReader ?


    I have xml
    Code:
    <ROWSET>
     <ROW>
      <TOTALROWS>4</TOTALROWS>
      <KEY>1</KEY>
      <ID type="int">1</ID>
      <CODE type="string">AS_ADMIN</CODE>
      <DESCRIPTION type="string">Администратор AS</DESCRIPTION>
     </ROW>
    </ROWSET>
    I want to get the variable xmlReader by url (or another), but not hard coded. How can I do that?
    Code:
     function xmlFn(){
                    var xmlReader = "{"+
                                    "name: 'ID',"+
                                    "type: 'int'"+
                                    "}@ {"+
                                    "name: 'CODE',"+
                                    "type: 'string'"+
                                    "}@ {"+
                                    "name: 'DESCRIPTION',"+
                                    "type: 'string'"+
                                    "}";
                     var xmlReaderArr = xmlReader.split("@");
                     var xmlReaderArrOut = new Array();;
                     for (var key in xmlReaderArr) {
                        var val = xmlReaderArr [key];
                        xmlReaderArrOut[key] = Ext.util.JSON.decode(val);
                    }
                 return xmlReaderArrOut;
                };
                     grid = new Ext.app.ux.FormEditGrid2({
                        id: 'grid_filter',
                        store: new Ext.data.Store({
                            id: 'store_objecttype',
                            url: 'data/role_table.xml',
                            // the return will be XML, so lets set up a reader
                            reader: new Ext.data.XmlReader({
                                record: 'ROW',
                                id: 'KEY',
                                totalProperty: "TOTALROWS",
                                fields: xmlFn()//xmlReaderArrOut
                            })
                        }),
                        columns: [{
                                        header: "Id",
                                        dataIndex: 'ID',
                                        width: 50,
                                        //hidden: true,
                                        sortable: true/*,
                                        editor: */
                                    }, {
                                        header: "Code",
                                        dataIndex: 'CODE',
                                        width: 110,
                                        sortable: true,
                                        editor: new Ext.form.TextField({
                                            allowBlank: false
                                        })
                                    }, {
                                        header: "Description",
                                        dataIndex: 'DESCRIPTION',
                                        width: 300,
                                        sortable: true,
                                        editor: new Ext.form.TextField({
                                            allowBlank: false
                                        })
                                    }], 
    
    
                        viewConfig: {
                            forceFit: true //для resize колонок
                        },
                     
                        autoExpandColumn: 'Id',
                        title: 'AS_ROLE table',
    
    
                        updater: {
                            insertCommand: 'p_ovc_role_table.create_object_type',
                            updateCommand: 'p_ovc_role_table.update_object_type',
                            deleteCommand: 'p_ovc_role_table.delete_object_type',
                            prefix: 'p_'
                        }/*, так не работает, т.к. поле ID проинициализированно
                        recordForm: {
                            ignoreFields: {
                                ID: false
                            }
                        }*/
                    });
    
    
                   grid.store.paramNames.start = "p_start"; //by default it is "start"
                   grid.store.paramNames.limit = "p_limit"; //by default it is "start"
                   grid.store.load({
                        params: {
                            p_start: 0,
                            p_limit: 30
    
    
                        }
                    });
                    
                    this.getComponent('ot_grid_panel').add(grid);

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    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 want to have dynamic fields in your Store?
    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
    Nov 2011
    Posts
    3
    Vote Rating
    0
    FOONTIK is on a distinguished road

      0  

    Default


    You want to have dynamic fields in your Store?
    Yes, I want dynamic fields.
    I need this part "fields: xmlFn()" as dynamic part.

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    3
    Vote Rating
    0
    FOONTIK is on a distinguished road

      0  

    Default


    Hi, everyone! Sorry I didn't give clearly explanation of my problem.

    The Ext.grid.GridPanel component is great, but I've found only examples where
    config-params "store" and "columns" have been hard-coded. I needed these configs as dynamic configs.

    I'll give code. I hope It may help someone

    Code:
    Ext.Ajax.request({
                                url: 'AjaxReq',//this is a servlet, which return json-object
                                params: {
                                    p_start: '1',
                                    p_limit: '25',
                                    p_filter: ''
                                },
                                scope: this,
                                disableCaching: true,
                                callback: function(options, success, response){
                                       
                                       response_Obj = response.responseText; 
                                       responseObj = Ext.util.JSON.decode(response_Obj);
                                       astore = responseObj.store
                                       acolumns = responseObj.columns
    
                             topPanel = new Ext.grid.GridPanel({
                                                        url: 'xxx.xml',
                                                        store: astore, 
                                                        columns: acolumns });
    
                             var win = new Ext.Window({ 
                                        ...
                                        items: [topPanel]
                                    }); 
    
                                       win.show(); 
    
    ...

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi