PDA

View Full Version : [ask] get key from store



y0uzha
5 Aug 2015, 1:31 AM
i have an example for data store like this:


[{
"Text": " alpha",
"qtip": {
" total":"300"
}
}]

and then i have grid column like this


[{
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 :

function(record){
for(y in record.get('qtip')){
console.log(record.get('qtip')[y]);
}
}


but it failed. please help me.

scottmartin
6 Aug 2015, 9:36 AM
Have a look at the other params in your renderer function:



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

y0uzha
6 Aug 2015, 6:06 PM
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 :


{
"qtip":{
"total1":"300",
"total2":"200",
"total3":"100"
}
}

how if i want to get only "total2" and "total3" ..??

f.baron
14 Aug 2015, 5:46 AM
...
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"
}
...