extjs - Grid rows with nested data from loaded store -


i have dataview gets loaded parameter. render data in template. trying use same data in there nested item render grid.

the data looks this:

{     "myjson": {         "name": "abc",         "type": "faulty",         "notes": [             {                 "date": "01-01-1970",                 "note": "test note"             },             {                 "date": "01-02-1970",                 "note": "test note 2"             }         ]     } } 

the store:

proxy: {                 type: 'ajax',                 url: '/api/detail/',                 reader: {                     type: 'json',                     root: 'myjson'                 }             } 

model:

    {         name:'name',     },     {         name:'type',     },     {         name:'notes',         mapping:'notes'     }, 

template:

{name} - {type} 

that works. i'd use notes chunk display in grid. problem can't read notes group.

var noteslistview = new ext.list.listview({     store: 'mystore',     multiselect: false,     width:'100%',     id:'noteslist',     columns: [{         header: 'date',         width: 75,         dataindex: 'date'     },{         header: 'note',         width: 150,         dataindex: 'note',     }] }); 

is possible this? or need create new store , model use group of data in grid?

i've tried mapping notes.date, instance, in both model

name:'note_date', mapping:'notes.date' 

and in grid

dataindex:'notes.date' 

neither of worked.

i've tried using renderer doesn't work either it's array

renderer:function(value, metadata, record, rowindex, colindex, store){     var value = value.date;//won't work; needs index la value[0].date     return value; } 

you create nested model same data receiving.

ext.define("jsonmodel", {   extend: 'ext.data.model',   fields: ['name','type'],   hasmany: [{       model: 'note',       name: 'notes'   }] });  ext.define("note", {   extend: 'ext.data.model',   fields: [       'date',       'note'] }); 

this way access children of give record this

var jsonrecordchildren = jsronrecord.notes() 

the variable jsonrecordchildren created of type store, assign attribute store of grid.

ext.create('ext.grid.panel', {   store: selectedrecord.notes(),   columns: [       { text: 'date',  dataindex: 'date' },       { text: 'note', dataindex: 'note'}   ],   renderto: ext.getbody() }); 

http://jsfiddle.net/alexrom7/rf8mt/2/


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -