PDA

View Full Version : Unable to put Bryntum Scheduler tree json data in external js file



jlimaye
2 Feb 2012, 10:52 PM
Hi,
for tree example of scheduler, Im unable to put flightStore in external js file. I try -


var flightStore = Ext.create('Ext.data.JsonStore', {
model : 'Sch.model.Event',
proxy : {
type : 'jsonp',
//the store will get the content from the .js file
url : 'app/eg/flightStore.js'
}
});
or

var flightStore = Ext.create('Ext.data.JsonStore', {
// model : 'Sch.model.Event',
proxy : {
type : 'ajax',
//the store will get the content from the .js file
url : 'app/eg/flightStore.js',
reader: {
type: 'json',
root: 'data'
// idProperty: 'name'
}
}
,fields: ['ResourceId', 'Name', 'Color',{name:'StartDate', type: 'date'}, {name:'EndDate', type:'date'}]
});

I have attached the js file where i declare the data for flightStore.

31311

Where am I going wrong?

mankz
2 Feb 2012, 11:11 PM
Proxy should be ajax, not jsonp.

jlimaye
2 Feb 2012, 11:13 PM
2nd code which I tried has proxy ajax. I even mapped the fields but still I was not able to view data into scheduler.

mankz
2 Feb 2012, 11:19 PM
Do you see rows rendered? Are you using a webserver? Any firebug errors?

jlimaye
2 Feb 2012, 11:22 PM
No firebug errors, and I dont see the data getting rendered. It puzzled me! I attached the json data file and the 2 ways I tried to declare the data in ext js. Can u give the snippet to declare the dataStore? I feel the 2nd code i posted to declare the dataStore is pretty close.

mankz
2 Feb 2012, 11:51 PM
Why Not start fresh with the flight sample in the Sdk that works? Hard to help without seeing all code and server responses etc. Should use the Bryntum forums for this btw :)

jlimaye
3 Feb 2012, 12:31 AM
Actually, i thought this might be an issue of dataStore so posted here. I just need to get the json data from external js file. If u can give me an example of sample json data being accessed from js file, that would work for me. I think I might be doing something wrong with the syntax.

mankz
3 Feb 2012, 12:37 AM
This sample already loads data from a static JS file, did you check it out?

http://www.bryntum.com/examples/scheduler-latest/examples/tree/tree.html

jlimaye
3 Feb 2012, 12:40 AM
there are 2 types accessed here. The 'get-data.js' file contains the tree hierarchy but the actual data that is mapped to scheduler is inside 'tree.js'. I simply want to take out the json data from tree.js and put it in some separate file. I thought this is a query regarding how to use dataStore externally, so asked in this forum. Thanks.

mankz
3 Feb 2012, 12:44 AM
You're right, it is :). Do you actually call load of that store at some point?

jlimaye
3 Feb 2012, 12:48 AM
I have to carry out a requirement like :
1. I have a dataStore already selected for scheduler.
2. on button click, I want to switch the dataStore to some other dataStore to display different data.
3. Main thing here is I want to store the json data outside in separate js files.

This is what Im trying to achieve. But due to lack of knowledge, Im unable to do it. Once I get the json data outside, then next steps will be easy.

mankz
3 Feb 2012, 12:55 AM
Ok, I updated the sample to your requirements - events are now loaded from event-data.js. Check source here:

http://www.bryntum.com/examples/scheduler-latest/examples/tree/tree.html

jlimaye
3 Feb 2012, 1:01 AM
Ok, I updated the sample to your requirements - events are now loaded from event-data.js. Check source here:

http://www.bryntum.com/examples/scheduler-latest/examples/tree/tree.html

Hi, Im not able to view the sample data in your example. Shall I download the trial version pack again to get the updated sample of tree? I can only see tree.js and no other source files.

Thanks.

mankz
3 Feb 2012, 1:04 AM
And what do you see if you open tree.js? Hint:


var flightStore = Ext.create('Ext.data.JsonStore', {
model : 'Sch.model.Event',
autoLoad : true,
proxy : {
type : 'ajax',
//the store will get the content from the .js file
url : 'event-data.js' // THIS SHOULD BE USEFUL :)
}
});

jlimaye
3 Feb 2012, 1:09 AM
Nope. I see the earlier sample where json data is entered directly into flightStore.

Im using the event-data.js file as


{
data :
[
{
ResourceId: 1000,
Name : 'Release',

StartDate : "2012-01-10 02:20",
EndDate : "2012-01-10 22:00"
},
...
.
.
.
]
}


Is it correct?

mankz
3 Feb 2012, 1:16 AM
Nope, clear your cache.

jlimaye
3 Feb 2012, 1:19 AM
Cleared my cache. Still, bryntum example gave me a firbug error 404 for 'get-data.js'. Thats why the sample is not working. Also I saw old tree.js where flightStore is entered directly.

mankz
3 Feb 2012, 1:23 AM
// Store holding all the departures
var flightStore = Ext.create('Ext.data.JsonStore', {
model : 'Sch.model.Event',
autoLoad : true,
proxy : {
type : 'ajax',
//the store will get the content from the .js file
url : 'event-data.js'
}
});

Url to the events changed, see above.

jlimaye
3 Feb 2012, 1:26 AM
thanks a lot!!!! got it.