Results 1 to 4 of 4

Thread: [ask] get key from store

  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    32

    Default [ask] get key from store

    i have an example for data store like this:

    Code:
    [{
    "Text": " alpha",
    "qtip": {
    " total":"300"
    }
    }]
    and then i have grid column like this

    Code:
    [{
    header: "Total Row",
    dataIndex:" qtip.total"
    }]
    if i run that code, the value of my grid for total row will be 300.
    well, how if i want to show the key, not "300" but "total" .??
    i've try to make function in renderer :
    Code:
    function(record){
    for(y in record.get('qtip')){    
         console.log(record.get('qtip')[y]);   
          }
       }
    but it failed. please help me.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Have a look at the other params in your renderer function:

    Code:
    renderer: function(value, metaData, record, rowIndex, colIndex){
        console.log(metaData.column.dataIndex);
    },

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    32

    Default

    hi thx for you reply,

    the result for your suggest is the value of dataIndex right. in my ex code above, the result will be "qtip". I can get "total" when i change the value of dataIndex to "total". But how if have store like this :

    Code:
    {
        "qtip":{
                     "total1":"300",
                     "total2":"200",
                     "total3":"100"
                 }
    }
    how if i want to get only "total2" and "total3" ..??

  4. #4

    Join Date
    Dec 2013
    Location
    Italy
    Posts
    88
    Answers
    9

    Default

    Code:
    ...
    dataIndex: 'qtip',
    renderer: function(value) {
        var totalAttr = Ext.Object.getKeys(value); //['total', 'total2', 'total3']
        // ... do logic
        // return value to render
        return totalAttr; // This will return joined array "total, total2, total3"
    }
    ...

Similar Threads

  1. Sencha Touch 2 example of syncing localStorage store with remote JSONP proxy store
    By lalexgraham in forum Sencha Touch 2.x: Examples and Showcases
    Replies: 4
    Last Post: 16 Jan 2014, 6:07 AM
  2. Replies: 2
    Last Post: 12 Nov 2012, 12:37 PM
  3. Replies: 3
    Last Post: 22 May 2012, 7:56 PM
  4. Replies: 4
    Last Post: 23 Aug 2010, 12:44 PM
  5. Replies: 2
    Last Post: 29 Jul 2009, 9:12 AM

Posting Permissions

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