In this example I will demonstrate how to use an ExtJS4 store to perform an XML data read from an ASP.NET MVC3 controller. First let me say that I wasted a LOT of time reading fake tutorials on these keywords – seems there are a lot of people who can explain the ASP.NET MVC3 side, but not how to actually connect it to an ExtJS4 store using a clean proxy, AND pass parameters to the server. Especially using XML for the return data.
So, let’s say we just want a basic search box – when user types something in and hits Search, we will use an ExtJS4 store and POST to an ASP.NET MVC3 method, passing the search query as a JSON parameter, while returning results in XML. Here’s the basic ExtJS model & store configuration:
// Basic model Ext.define('MY.model.SearchResult', { extend: 'Ext.data.Model', fields: ['id','html'] }); // Basic store Ext.create('Ext.data.Store',{ model: 'MY.model.SearchResult', proxy: Ext.create('MY.proxy.MSAjaxProxy', { url: '/User/Search', reader: { type: 'xml', root: 'matches', record: 'match' } }) // eo proxy }) // eo store |