salon software stephen
24 Jan 2011, 4:39 PM
Hi,
I'm trying to figure out how to access one piece of data that is stored above the root I have specified for my Json reader
My model is defined as follows:
Ext.regModel('Booking', {
fields: ['id', 'start', 'end', 'title', 'service', 'service_id', 'client_note', 'stylist_note', 'utc_start', 'day_date', 'start_time']
});My store is defined like:
var store = new Ext.data.JsonStore({
model : 'Booking',
sorters: 'utc_start',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'includes/get_appointments.php',
extraParams: {
req_start: '1295251200',
req_end: '1295856000',
stylist_id: '9'
},
reader: {
type: 'json',
root: 'events'
}
},
listeners: {
load:function(store, records, success) {
// -------------------------*****---------------------
// this is where i would like to be able to retrieve the extra json value
// -------------------------*****---------------------
for (var i = 0; i < records.length; i++){
// doing stuff with the returned records....
}
}
}
},
getGroupString : function(record) {
return record.get('day_date'); // optional char from array removed
}
}); An example of what my JSON looks like (with only 1 event for simplicity):
{"page_num":"52", "events":[{"id":"3744","start":"2011-01-18T10:00:00-08:00","end":"2011-01-18T11:00:00-08:00","title":"Claire Preston","service":"Women's haircut","service_id":"96","client_note":"","stylist_note":"","utc_start":"1295373600"}]} I can access the data within each event with no problem.
What I need to be able to do is access the page_num value from within the Listener that I have declared.
I can see how to assign page_num to totalProperty, but can't see how to fetch its value properly.
Thanks so much for any assistance you can offer.
I'm trying to figure out how to access one piece of data that is stored above the root I have specified for my Json reader
My model is defined as follows:
Ext.regModel('Booking', {
fields: ['id', 'start', 'end', 'title', 'service', 'service_id', 'client_note', 'stylist_note', 'utc_start', 'day_date', 'start_time']
});My store is defined like:
var store = new Ext.data.JsonStore({
model : 'Booking',
sorters: 'utc_start',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'includes/get_appointments.php',
extraParams: {
req_start: '1295251200',
req_end: '1295856000',
stylist_id: '9'
},
reader: {
type: 'json',
root: 'events'
}
},
listeners: {
load:function(store, records, success) {
// -------------------------*****---------------------
// this is where i would like to be able to retrieve the extra json value
// -------------------------*****---------------------
for (var i = 0; i < records.length; i++){
// doing stuff with the returned records....
}
}
}
},
getGroupString : function(record) {
return record.get('day_date'); // optional char from array removed
}
}); An example of what my JSON looks like (with only 1 event for simplicity):
{"page_num":"52", "events":[{"id":"3744","start":"2011-01-18T10:00:00-08:00","end":"2011-01-18T11:00:00-08:00","title":"Claire Preston","service":"Women's haircut","service_id":"96","client_note":"","stylist_note":"","utc_start":"1295373600"}]} I can access the data within each event with no problem.
What I need to be able to do is access the page_num value from within the Listener that I have declared.
I can see how to assign page_num to totalProperty, but can't see how to fetch its value properly.
Thanks so much for any assistance you can offer.