mikegiddens
2 Dec 2006, 5:43 PM
I am not sure if it is me or a bug but I would imagine it is me.
My main issue is a sub grid is being created from a call:
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
and in that function I call a function to create a new grid in a div that was dynamically created in the showSchoolInfo function. Everything seems to work but there is a major side effect with the col listener. For some reason the inital grid is linked to the sub grid col widths. I have set up different DefaultColumnModel for the different grids.
Example Posted here:
http://www.michaelgiddens.com/project/schools.html
Code Used:
var Organization = {
init : function(schoolID) {
var schema2 = {
tagName: 'Item',
id: 'OrganizationID',
fields: ['School', 'State', 'City']
};
dataModel2 = new YAHOO.ext.grid.XMLDataModel(schema2);
var colModel2 = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Organization", width: 100, sortable: true},
{header: "Symbols", width: 50, sortable: false},
{header: "Type", width: 50, sortable: true}
]);
// create the Grid
grid2 = new YAHOO.ext.grid.Grid('org-grid', dataModel2, colModel2);
grid2.autoWidth = true;
grid2.autoHeight = true;
grid2.render();
var file = "school-" + schoolID + ".xml";
dataModel2.load(file);
}
}
var Schools = {
init : function(){
body = new YAHOO.ext.Actor('school-info');
var schema = {
tagName: 'Item',
id: 'SchoolID',
fields: ['School', 'State', 'City']
};
dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "School", width: 220, sortable: true},
{header: "State", width: 150, sortable: true},
{header: "City", width: 115, sortable: true}
]);
// create the Grid
selModel = new YAHOO.ext.grid.SingleSelectionModel();
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
grid = new YAHOO.ext.grid.Grid('school-grid', dataModel, colModel, selModel);
grid.autoWidth = true;
grid.autoHeight = true;
grid.render();
dataModel.load('schools.xml');
},
showSchoolInfo : function(selModel, row, selected){
if(selected){
var dm = dataModel;
var node = dm.getNode(row.rowIndex);
var link = dm.getNamedValue(node, 'DetailPageURL');
var schoolID = dm.getNamedValue(node, 'SchoolID');
var school = dm.getNamedValue(node, 'School');
var state = dm.getNamedValue(node, 'State');
var city = dm.getNamedValue(node, 'City');
html = "School: " + school;
html += "
State: " + state;
html += "
City: " + city;
html += "
<div></div>"
html += "
School Profile ('" + link + "')"
body.startCapture(true);
// body.hide(true, .1);
body.update(html);
body.show(true, .2);
body.play();
///////////////////////
// Call to Create Nested Table
///////////////////////
Organization.init(schoolID);
//////////////////////////////
}
}
}
YAHOO.ext.EventManager.onDocumentReady(Schools.init, Schools, true);
Any insite on why this happens or if this could be a bug?
Question 2:
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
It seems this also listens for a click on the title bar as well and was wondering if there was anyway to know the difference when the title bar is clicked and an actual row?
Cheers
My main issue is a sub grid is being created from a call:
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
and in that function I call a function to create a new grid in a div that was dynamically created in the showSchoolInfo function. Everything seems to work but there is a major side effect with the col listener. For some reason the inital grid is linked to the sub grid col widths. I have set up different DefaultColumnModel for the different grids.
Example Posted here:
http://www.michaelgiddens.com/project/schools.html
Code Used:
var Organization = {
init : function(schoolID) {
var schema2 = {
tagName: 'Item',
id: 'OrganizationID',
fields: ['School', 'State', 'City']
};
dataModel2 = new YAHOO.ext.grid.XMLDataModel(schema2);
var colModel2 = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Organization", width: 100, sortable: true},
{header: "Symbols", width: 50, sortable: false},
{header: "Type", width: 50, sortable: true}
]);
// create the Grid
grid2 = new YAHOO.ext.grid.Grid('org-grid', dataModel2, colModel2);
grid2.autoWidth = true;
grid2.autoHeight = true;
grid2.render();
var file = "school-" + schoolID + ".xml";
dataModel2.load(file);
}
}
var Schools = {
init : function(){
body = new YAHOO.ext.Actor('school-info');
var schema = {
tagName: 'Item',
id: 'SchoolID',
fields: ['School', 'State', 'City']
};
dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "School", width: 220, sortable: true},
{header: "State", width: 150, sortable: true},
{header: "City", width: 115, sortable: true}
]);
// create the Grid
selModel = new YAHOO.ext.grid.SingleSelectionModel();
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
grid = new YAHOO.ext.grid.Grid('school-grid', dataModel, colModel, selModel);
grid.autoWidth = true;
grid.autoHeight = true;
grid.render();
dataModel.load('schools.xml');
},
showSchoolInfo : function(selModel, row, selected){
if(selected){
var dm = dataModel;
var node = dm.getNode(row.rowIndex);
var link = dm.getNamedValue(node, 'DetailPageURL');
var schoolID = dm.getNamedValue(node, 'SchoolID');
var school = dm.getNamedValue(node, 'School');
var state = dm.getNamedValue(node, 'State');
var city = dm.getNamedValue(node, 'City');
html = "School: " + school;
html += "
State: " + state;
html += "
City: " + city;
html += "
<div></div>"
html += "
School Profile ('" + link + "')"
body.startCapture(true);
// body.hide(true, .1);
body.update(html);
body.show(true, .2);
body.play();
///////////////////////
// Call to Create Nested Table
///////////////////////
Organization.init(schoolID);
//////////////////////////////
}
}
}
YAHOO.ext.EventManager.onDocumentReady(Schools.init, Schools, true);
Any insite on why this happens or if this could be a bug?
Question 2:
selModel.onRowSelect.subscribe(this.showSchoolInfo, this, true);
It seems this also listens for a click on the title bar as well and was wondering if there was anyway to know the difference when the title bar is clicked and an actual row?
Cheers