PDA

View Full Version : how to load a store on button click?



snow_cap
31 Oct 2011, 2:53 PM
I was able to load the store on the load of the page,but when i try to load the data into the store on button click using Ext.Ajax.request the data in the store are never binded and items length is equal to 0.
am using the following:


var ds= new Ext.data.JsonStore({


proxy: new Ext.data.HttpProxy({ url: 'handler1.ashx'
}),


id: 'strGrid',
fields: ['DOC_ID', 'DOC_STATUS', 'docDate', 'DOC_MAILNUM', 'DOC_SUBJECT', 'DOC_BARCODE']
});
Ext.Ajax.request({
method: 'GET',




url: 'handler1.ashx',
success: function (response, request) {
ds.loadData(Ext.encode(response.responseText));
}
});


Any ideas?Is there any example where the store is loaded on button click?
Thanking you in advance

P.S.:I debugged the function it's successful and returning the correct data in the response.responsetext

JambaFun
31 Oct 2011, 3:57 PM
Hi snow_cap,

Here http://docs.sencha.com/ext-js/4-0/#!/guide are some great guides that will teach you how to work with Ext JS 4!

Your example is best solved with a store that loads its data through a JsonProxy. The loading is triggered from a controller listening for button clicks in a view. All of these concepts are KEY to understanding what Ext JS is all about and not really something you can except to be taught in a single forum post.

Best Regards