user2420811
user2420811

Reputation: 13

pass data from controller to extjs table

I have variables in a controller and I want to display the data from those variables in a extjs xtemplate table.

I had the following line in my controller but nothing passed through:

this.getBookOrdersTable().data = {name:BookName, date:OrderDate};

BookOrdersTable is a name given to a reference to my table. BookName and OrderDate are the variables with the data that I need.

The code for my table is

    this.data = {
        Books: [

        ]
    };

this.tpl = new Ext.XTemplate('<h1 style="font-size: 2em; padding-bottom: 10px;">Book Orders</h1>',
    '<tpl for="Books">',
    '<table>',
    '<tr>',
    '<th>Book Name: </th>',
    '<td>{name}</td>',
    '</tr>',
    '<tr>',
    '<th>Order Date: </th>',
    '<td>{date}</td>',
    '</tr>',
    '</table>',
    '</tpl>');

this.callParent();
}

Any help would be appreciated!

Upvotes: 1

Views: 165

Answers (1)

Towler
Towler

Reputation: 1562

If the object is already instantiated, setting the data property won't do anything. You need to call update.

this.getBookOrdersTable().update({
   Books: [
      {name:BookName, date:OrderDate}
   ]
});

Upvotes: 1

Related Questions