PDA

View Full Version : Import & Export JSON file in EXTJS 3.4



sudhir.gupta.eck
10 Dec 2015, 3:29 AM
Hello,

I am newly into EXTJS 3.4.
I am trying to import the JSON file stored locally in my system . But not able to load the file in grid.

Here is the code .



JSONData.json

{"users":[
{"id" : 1,"name" : "Sudhir Gupta","email" : "[email protected]"},
{"id" : 2,"name" : "Anna Smith","email" : "[email protected]"},
{"id" : 3,"name" : "Peter Smith","email" : "[email protected]"},
{"id" : 4,"name" : "Tom Smith","email" : "[email protected]"},
{"id" : 5,"name" : "Andy Smith","email" : "[email protected]"},
{"id" : 6,"name" : "Nick Smith","email" : "[email protected]"}
]}

JsonLogic.js----
Ext.onReady(function() {
var grid = new Ext.grid.GridPanel({
renderTo : Ext.getBody(),
frame : true,
title : 'Database',
width : 500,
height : 600,
store : Grid1Store,
columns : [ {
header : "Id",
dataIndex : 'id'
}, {
header : "Name",
dataIndex : 'name'
}, {
header : "Email",
dataIndex : 'email'
} ]
});
});


var Grid1Store = new Ext.data.JsonStore({
fields: [ 'id', 'name', 'email' ],
autoLoad: true,
proxy:{
type:'ajax',
url:'JSONData.json' (https://www.sencha.com/forum/'JSONData.json'),
reader:{
type: 'json',
root:'users'
}
}
});


Please also tell me what should be the URL If I want to load JSON file locally from a folder structure ( like at C:/data/test/abc.json )

Gary Schlosberg
10 Dec 2015, 5:53 AM
This example (http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/paging.html) uses a JSON store, perhaps it will help. As far as the path, I would try using one relative to your code file.

sudhir.gupta.eck
14 Dec 2015, 12:17 AM
Hi Gary, Thanks for your response. It worked for me. Do you have any idea about how to export JSON from a gird . I mean how to create json from a gird values and export it to a json.

Gary Schlosberg
14 Dec 2015, 1:23 PM
Are you trying to get your data back to the server or to allow a user to export it?