View Full Version : value from rawData insert to grid

24 Apr 2014, 2:14 AM
I am have store, window and grid in this form. I am want insert to grid value from store. On picture i am pointed what data i am want insert :



Ext.onReady(function () {
{ extend:
fields: [
] });


var myStore = Ext.create('Ext.data.Store', {
model: 'RRD',
autoLoad: true,
proxy: {
type: 'ajax',
url: '/price/books',
reader: { type: 'json',
root: 'data',
successProperty: 'status' }
} });

Table and window:

var myTable = Ext.create('Ext.grid.Panel', { store: myStore,
columns: [
{ text : 'Value', sortable : true, dataIndex: 'data', flex: 0, width: 100 }, ],
height: 900,
width: 300,
title: 'Data'});
var win = Ext.create('Ext.Window', {
width: 800, height: 600,
minHeight: 400,
minWidth: 550,
hidden: false,
maximizable: true,
title: 'RRD Table',
renderTo: Ext.getBody(),
layout: 'fit',
items: [myTable] });

24 Apr 2014, 11:18 PM
what is the response you send back to the store? once the store is loaded, the data in the store will appear automatically in the grid (because the store is bound to the grid).

25 Apr 2014, 2:12 AM
i have this response from server

{status: "SUCCESS",msg: "???????? ????????? ???????",data: ["???????","????????"]}

25 Apr 2014, 2:27 AM
your response is not in the right format. "data" is the root element which you have correctly configured but you dont have any fields defined in it. data in your response should be something like:

data: [{'fieldname': '12312'}, {'fieldname': 'asdasfa'}, {'fieldname': 'wf'}]

assuming that you only have one field 'fieldname' in your model and this you also use as the dataIndex in your grid's column, it should work. Inside data array, you have JSON records separated by {}. Inside each record, you can have many fields (here only one is shown for example).

OR you can look at this http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.reader.Array