ASP.NET MVC3 XML & ExtJS4

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

Continue reading ASP.NET MVC3 XML & ExtJS4

VN:F [1.9.22_1171]
Rating: 6.9/10 (9 votes cast)

ASP.NET AJAX & ExtJS 4 Grid (4)

Read Previous Example First!

In this example, we’ll improve our ExtJS 4 model to include an “association” that it will read from XML produced by AJAX call to ASP.NET. Most common association is one to many, for example: your Client can place multiple Orders. An ExtJS 4 data store and model can accommodate this.

The new XML data packet will look like this; notice hiddenAttributes:

<?xml version="1.0" encoding="utf-8"?>
<matches>
	<match>
		<id>0</id>
		<name>Number 0</name>
		<hiddenAttributes>
			<attr>
				<name>hidden1</name>
				<value>val1</value>
			</attr>
			<attr>
				<name>hidden2</name>
				<value>val2</value>
			</attr>
		</hiddenAttributes>
	</match>
	<match><id>1</id><name>Number 1</name></match>
	...
</matches>

Continue reading ASP.NET AJAX & ExtJS 4 Grid (4)

VN:F [1.9.22_1171]
Rating: 6.8/10 (5 votes cast)

ASP.NET AJAX & ExtJS 4 Grid (3)

Read Previous Example First!

In this example, we’ll be returning additional data to our ExtJS4 data store, which is passed from ASP.NET over AJAX in XML format. It’s common to show grid row count in the form title, as well as something else in the header, such as final SQL or LDAP query used by your ASP.NET AJAX script (WebMethod).

Combine this with ExtJS4 buffered grid’s ability to only render 50 HTML rows with infinite scrolling, this makes  the stock ExtJS4 gridpanel an extremely powerful application in its own right, very good at running large data queries.  On a decent computer with decent Internet connection this will smoke the traditional buffered grid, which ajax back on every scroll.


Continue reading ASP.NET AJAX & ExtJS 4 Grid (3)

VN:F [1.9.22_1171]
Rating: 8.3/10 (6 votes cast)

ASP.NET AJAX & ExtJS 4 Grid (2)

In this example series we’ll keep using MSAjaxProxy we set up earlier, for working with IIS 6+ running MS AJAX Extensions 1.0

In this example we’ll set up an ExtJS4 gridpanel with infinite scrolling, using XML data served from ASP.NET. Sometimes this is also called “buffered grid.” Sencha provides an example using memory store, but it took me some time to figure this one out, so enjoy!


Continue reading ASP.NET AJAX & ExtJS 4 Grid (2)

VN:F [1.9.22_1171]
Rating: 6.4/10 (5 votes cast)

ASP.NET AJAX & ExtJS 4 Grid (1)

In this example series we’ll keep using MSAjaxProxy we set up earlier, for working with IIS 6+ running MS AJAX Extensions 1.0

We’ll set up an ExtJS4 gridpanel with infinite scrolling, using XML data served from ASP.NET. This is a native feature of ExtJS4, but I have not seen a single example from Sencha, explaining how to do this with a real proxy. It is a great feature though, as you can have a 100,000 record data set, with only 50 HTML table rows on the screen at any given time.

ExtJS4 Store & Model configuration is trivial:

// Model
Ext.define('MyOrg.model.SearchResult', {
	extend: 'Ext.data.Model'
	, fields: ['id','name']
});
 
// Store
Ext.create('Ext.data.Store',{
	model: 'MyOrg.model.SearchResult'
	, proxy: Ext.create('MyOrg.proxy.MSAjaxProxy', {
		url: 'Default-UMRA.aspx/Search'
		, reader: { type: 'xml', root: 'matches', record: 'match' }
		, extraParams: { query: 'Param to C#' }
	}) // eo proxy
})

Continue reading ASP.NET AJAX & ExtJS 4 Grid (1)

VN:F [1.9.22_1171]
Rating: 5.7/10 (6 votes cast)