View Full Version : Column field mapping, does not work.

12 Jul 2013, 3:16 AM
I work on JSONSTORE to get data via AJAX mechanism. But some how it is not working with mapping property.
Each time for 95 columns with 100 rows in page, it is useless to get data with "name","email","phone" string each time.

I want to use something simmilar to below example.

Please find below example which does not work.

Ext.create('Ext.data.Store', {
fields:[{name:'name', mapping:2}, {name:'email', mapping:1}, {name:'phone', mapping :0}],
{'Lisa', "lisa@simpsons.com","555-111-1224" },
{'Bart',"bart@simpsons.com","555-222-1234" },
{'Homer',"home@simpsons.com","555-222-1244" },
{'Marge',"marge@simpsons.com","555-222-1254" }
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
height: 200,
width: 400,
renderTo: Ext.getBody()

12 Jul 2013, 4:34 AM
Your Data are static or dynamic? Bcoz your code seems like it is static.
If static, You can use array store like the below eg

ExpData = [
['Past', 5.6],
['Past', 5.6],
['TA', 0.7],
['TA', 6.3],
var ExpStore = Ext.create('Ext.data.ArrayStore', {
fields: [{name : 'role'},{name : 'exp'}],
data: ExpData

12 Jul 2013, 4:48 AM
My data are dynamic, but mapping does not work on it, so tried on API on static data.
But even API code also raise error.

14 Jul 2013, 4:54 PM
{'Lisa', "lisa@simpsons.com","555-111-1224" }

This isn't JSON, or even JavaScript; it's just a mangle of symbols. Do you mean this?

["Lisa", "lisa@simpsons.com", "555-111-1224"]

Note the square brackets for an array.

To process an array you'd use an array reader rather than a JSON reader.