jbowman
3 Dec 2006, 6:49 PM
Is there any way to get to the jsonview data model? The jsonData propery is showing as undefined currently. I'm trying to create a few views from one json request, and right now my current idea is that since the jsonView is nice and sets up the datamodel so I can use names for the indexes, rather than index number, I'd like to
Create jsonView and "load" it. Create a contentPanel in my layout from that.
Get the datamodel, and create new view, assigning it the same datamodel, different jsonRoot.
Use that to add another contentPanel to my layout.
Here's the block of code I'm working with. Note: The alert I have in there is coming up "undefined".
var dh = YAHOO.ext.DomHelper;
dh.append(document.body, {tag: 'div', id: 'editUserDialog-user'});
var tpl = new YAHOO.ext.Template('<div>Username: {username}</div>' +
'<div>Birthday: {birthday}</div>' +
'<div>Member Since: {join_date}</div>' +
'<div>Last Login: {last_login}</div>');
tpl.compile();
var mainView = new YAHOO.ext.JsonView('editUserDialog-user',
tpl, {jsonRoot: 'user'});
mainView.load("/ci/admin/edit_user", "id=" + id);
alert(mainView.jsonData);
var eulayout = editUserDialog.getLayout();
eulayout.add('center', new YAHOO.ext.ContentPanel('editUserDialog-user', {title: 'Main Info'}));
editUserDialog.show();
Here's my JSON in it's current state (fields will eventually be the field data, not the model, but hey, still working on it here :))
{"user":[{"id":"7","username":"testcom","birthday":"1987-11-12","join_date":"2006-11-12","last_login":"2006-11-24","categories":[{"cat_name":"Basic Info","cat_id":"1","fields":[{"id":"1","name":"sex","cat":"1","type":"radio"}]},{"cat_name":"Interests and Personality","cat_id":"20","fields":[{"id":"3","name":"Self Description","cat":"20","type":"multi-line"}]}]}]}
Create jsonView and "load" it. Create a contentPanel in my layout from that.
Get the datamodel, and create new view, assigning it the same datamodel, different jsonRoot.
Use that to add another contentPanel to my layout.
Here's the block of code I'm working with. Note: The alert I have in there is coming up "undefined".
var dh = YAHOO.ext.DomHelper;
dh.append(document.body, {tag: 'div', id: 'editUserDialog-user'});
var tpl = new YAHOO.ext.Template('<div>Username: {username}</div>' +
'<div>Birthday: {birthday}</div>' +
'<div>Member Since: {join_date}</div>' +
'<div>Last Login: {last_login}</div>');
tpl.compile();
var mainView = new YAHOO.ext.JsonView('editUserDialog-user',
tpl, {jsonRoot: 'user'});
mainView.load("/ci/admin/edit_user", "id=" + id);
alert(mainView.jsonData);
var eulayout = editUserDialog.getLayout();
eulayout.add('center', new YAHOO.ext.ContentPanel('editUserDialog-user', {title: 'Main Info'}));
editUserDialog.show();
Here's my JSON in it's current state (fields will eventually be the field data, not the model, but hey, still working on it here :))
{"user":[{"id":"7","username":"testcom","birthday":"1987-11-12","join_date":"2006-11-12","last_login":"2006-11-24","categories":[{"cat_name":"Basic Info","cat_id":"1","fields":[{"id":"1","name":"sex","cat":"1","type":"radio"}]},{"cat_name":"Interests and Personality","cat_id":"20","fields":[{"id":"3","name":"Self Description","cat":"20","type":"multi-line"}]}]}]}