View Full Version : this.dataModel has no properties

20 Oct 2006, 3:06 PM
I am getting that error when running the following code and I was just wondering if someone can explain why.

error-this.dataModel has no properties

<title>Grid Component 3</title>
function init() {
//initialize the data table component
function initDataTable() {
// data
var rows = [
// dataModel
var dm = YAHOO.ext.grid.DefaultDataModel(rows);

var sort = YAHOO.ext.grid.DefaultColumnModel.sortTypes;
// columns
var cols = [
{header: "First Name", sortable:true, sortType: sort.asUCString},
{header: "Last Name", sortable:true, sortType: sort.asUCString},
{header: "Age", sortable:true, sortType: sort.asInt}
// column model
var cm = YAHOO.ext.grid.DefaultColumnModel(cols);

this.grid = new YAHOO.ext.grid.Grid('contactList', dm, cm);
// on load event handler
YAHOO.util.Event.on(window, "load", init);



20 Oct 2006, 3:52 PM
You are using this within a function that wasn't called with new. Take a look at the example posts on my blog for an idea of how to call it within an object (or you could remove the this).

20 Oct 2006, 4:02 PM
Thanks, I just figured it out.