nagarajan.bose
10 Jan 2011, 8:46 AM
Hi,
We are extending a listview and it works fine when I load the data directly from store. However I have a situation, where I need to make an AJAX call and load the data using store.loadData(Ext.decode(response.Text)), it fails with an error "o is undefined".
Working Code:
SearchResults = Ext.extend(Ext.list.ListView, {
id : 'lvresults',
singleSelect : true,
emptyText : '<div style="padding:5px;">No results to display</div>',
title : 'Search Results',
reserveScrollOffset : true,
hideHeaders : true,
fields : ['id', {
name : 'gdate',
type : 'date',
dateFormat : 'c'
}],
columns : [{
dataIndex : 'gdate',
xtype : 'datecolumn',
format : 'D M d Y, G:i T'
}],
initComponent : function() {
this.tpl = new Ext.XTemplate(
'<tpl for="rows">',
'<dl class="x-grid3-row {[xindex % 2 === 0 ? "" : "x-grid3-row-alt"]}">',
'<tpl for="parent.columns">',
'<dt style="width:{[values.width*100]}%;text-align:{align};">',
'<em unselectable="on"<tpl if="cls">class="{cls}"</tpl>>{[values.tpl.apply(parent)]}',
'</em></dt></tpl><div class="x-clear"></div></dl></tpl>')
this.store = new Ext.data.JsonStore({
url:"/data/json/mmmmm/xxxxx.json",
root : 'rows',
idProperty : 'id',
fields : this.fields
})
SearchResults.superclass.initComponent.apply(this);
},
listeners : {
render : function() {
this.bindStore(this.store);
this.store.load();
}
}// eo listeners
});
Ext.reg(logviewresults', SearchResults);
Fails to load using the below code:
Ext.Ajax.request({
url:"/data/json/mmmmm/xxxxx.json",
success : function(response) {
Ext.getCmp("lvresults").store.loadData(Ext.decode(response.Text))
//Ext.getCmp("lvresults").bindStore(Ext.getCmp("lvresults").store) -->Tried this too... no use
},
failure : function(response){
//TODO: Handle failures here
}
})
Can any one point us where we are failing.
Thanks for your time and help.
Regards,
Nagaraj
We are extending a listview and it works fine when I load the data directly from store. However I have a situation, where I need to make an AJAX call and load the data using store.loadData(Ext.decode(response.Text)), it fails with an error "o is undefined".
Working Code:
SearchResults = Ext.extend(Ext.list.ListView, {
id : 'lvresults',
singleSelect : true,
emptyText : '<div style="padding:5px;">No results to display</div>',
title : 'Search Results',
reserveScrollOffset : true,
hideHeaders : true,
fields : ['id', {
name : 'gdate',
type : 'date',
dateFormat : 'c'
}],
columns : [{
dataIndex : 'gdate',
xtype : 'datecolumn',
format : 'D M d Y, G:i T'
}],
initComponent : function() {
this.tpl = new Ext.XTemplate(
'<tpl for="rows">',
'<dl class="x-grid3-row {[xindex % 2 === 0 ? "" : "x-grid3-row-alt"]}">',
'<tpl for="parent.columns">',
'<dt style="width:{[values.width*100]}%;text-align:{align};">',
'<em unselectable="on"<tpl if="cls">class="{cls}"</tpl>>{[values.tpl.apply(parent)]}',
'</em></dt></tpl><div class="x-clear"></div></dl></tpl>')
this.store = new Ext.data.JsonStore({
url:"/data/json/mmmmm/xxxxx.json",
root : 'rows',
idProperty : 'id',
fields : this.fields
})
SearchResults.superclass.initComponent.apply(this);
},
listeners : {
render : function() {
this.bindStore(this.store);
this.store.load();
}
}// eo listeners
});
Ext.reg(logviewresults', SearchResults);
Fails to load using the below code:
Ext.Ajax.request({
url:"/data/json/mmmmm/xxxxx.json",
success : function(response) {
Ext.getCmp("lvresults").store.loadData(Ext.decode(response.Text))
//Ext.getCmp("lvresults").bindStore(Ext.getCmp("lvresults").store) -->Tried this too... no use
},
failure : function(response){
//TODO: Handle failures here
}
})
Can any one point us where we are failing.
Thanks for your time and help.
Regards,
Nagaraj