1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    78
    Vote Rating
    0
    nick saint is on a distinguished road

      0  

    Default passing a few variable for each grid cell

    passing a few variable for each grid cell


    Hi,
    I am trying to pass two or more veriables for each cell of the grid but looks like cannot figure out how. All of them are numbers. At first I decided to pass it as string like 23|34, render, split and do the rest math calculation and finaly display the result. But I turned out cannot sort the the grid.
    Is there some other way to pass a few variables or object as a grid cell value?
    Thank you
    Nick
    [IMG]file:///C:/DOCUME%7E1/9335%7E1/LOCALS%7E1/Temp/moz-screenshot.jpg[/IMG]
    Attached Images

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    See the convert option of Ext.data.Record.create

  3. #3
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Clarification: when you specify your fields, there is a config option for convert. 3.x docs for that have an example how to use:
    http://extjs.com/deploy/ext-3.0-rc1....member=convert

  4. #4
    Ext User
    Join Date
    Oct 2008
    Posts
    78
    Vote Rating
    0
    nick saint is on a distinguished road

      0  

    Default


    Thank you very much for answers. I will try it.

  5. #5
    Ext User
    Join Date
    Oct 2008
    Posts
    78
    Vote Rating
    0
    nick saint is on a distinguished road

      0  

    Default


    Looks like I do something wrong
    That's what I do:

    HTML Code:
    Ext.onReady(function(){
    
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    
    function fullName(v, record){
        return record.name.last + ', ' + record.name.first;
    }
    
    function location(v, record){
        return !record.city ? '' : (record.city + ', ' + record.state);
    }
    
    var Dude = Ext.data.Record.create([
        {name: 'fullname',  convert: fullName},
        {name: 'firstname', mapping: 'name.first'},
        {name: 'lastname',  mapping: 'name.last'},
        {name: 'city', defaultValue: 'homeless'},
        'state',
        {name: 'location',  convert: location}
    ]);
    
    var store = new Ext.data.Store({
        reader: new Ext.data.JsonReader(
            {
                idProperty: 'key',
                root: 'daRoot',
                totalProperty: 'total'
            },
            Dude  // recordType
        )
    });
    
    var myData = [
        { key: 1,
          name: { first: 'Fat',    last:  'Albert' }
          // notice no city, state provided in data object
        },
        { key: 2,
          name: { first: 'Barney', last:  'Rubble' },
          city: 'Bedrock', state: 'Stoneridge'
        },
        { key: 3,
          name: { first: 'Cliff',  last:  'Claven' },
          city: 'Boston',  state: 'MA'
        }
    ];
        store.loadData(myData);
    
        var grid = new Ext.grid.GridPanel({
            store: store,
            columns: [
                {id:'fullname',header: "fullname", width: 160, sortable: true, dataIndex: 'fullname'},
                {header: "firstname", width: 75, sortable: true, dataIndex: 'firstname'},
                {header: "lastname", width: 75, sortable: true, dataIndex: 'lastname'},
                {header: "state", width: 75, sortable: true, dataIndex: 'state'},
                {header: "city", width: 75, sortable: true, dataIndex: 'city'},
                {header: "location", width: 85, sortable: true, dataIndex: 'location'}
            ],
            stripeRows: true,
            autoExpandColumn: 'fullname',
            height:350,
            width:600,
            title:'Array Grid',
            renderTo: document.body
        });
    });
    Pls, point out the mistake.
    Thank you
    Nick

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    So your data contains a property called "daRoot" does it? Which is the Array of rows? Like the manual says?

  7. #7
    Ext User
    Join Date
    Oct 2008
    Posts
    78
    Vote Rating
    0
    nick saint is on a distinguished road

      0  

    Default


    Thank you. I am a little bit slow. Got the idea:
    var myData =
    {daRoot: [
    { key: 1,
    name: { first: 'Fat', last: 'Albert' }
    // notice no city, state provided in data object
    },
    { key: 2,
    name: { first: 'Barney', last: 'Rubble' },
    city: 'Bedrock', state: 'Stoneridge'
    },
    { key: 3,
    name: { first: 'Cliff', last: 'Claven' },
    city: 'Boston', state: 'MA'
    }
    ]};
    Is it correct? It does work...

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    If it works, then it's correct.

  9. #9
    Ext User
    Join Date
    Oct 2008
    Posts
    78
    Vote Rating
    0
    nick saint is on a distinguished road

      0  

    Default


    Hi again
    I have another hard-to-get case
    HTML Code:
        var store = new Ext.data.JsonStore({
            id:'group',
            totalProperty:'totalCount',
            root:'rateitems',
            url:'<?= HTTP_SERVER;?>layouts/settings/gen/coresetrateout.php',
            fields: [
               {name: 'group', mapping: 'discr.group'},
               {name: 'sipp', type: 'string', mapping: 'discr.sipp'},
               {name: 'exampl', type: 'string', mapping: 'discr.exampl'},
               {name: 'kpp', type: 'string', mapping: 'discr.kpp'}
    
    <?php
              foreach($daylist as $key => $val){    
                echo ",{name: '".$val."', type: 'string', convert: getRate}\n"; 
              }
    ?> ]});
    
    I have JSON like:
    { discr: {
              group :"A",
              sipp :"ecmr",
              exampl :"hyundai atos",
              kpp :"+" },
     rate: { 
           "t3": {netto: "30", brutto: "35"}, 
           "t7": {netto: "24", brutto: "26"}, 
           "t8": {netto: "24", brutto: "26"}, 
           "t14": {netto: "23", brutto: "26"} } } 
    
    the convert function:
    
    function getRate(rec){
        console.log(rec.rate);
    };
    I understand that to get the netto value I have to use console.log(rec.rate.t3.netto);
    but as far as I do not know what will follow after rec.rate.???.netto I cannot get the value.
    Is there any way to get it?
    Thank you
    Nick

  10. #10
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Can you just use for in loop, or Ext.each to loop the contents of that property?

Thread Participants: 2

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