PDA

View Full Version : Exjts 4 and ASP MVC3



alejandro-mosquera
27 Nov 2011, 8:55 PM
Hi!

My question has to do primarily with the development of an application: MVC3 with C# and Extjs 4I have a model Extjs4 defined as:

Ext.define ('MyApp.model.User', {
extend 'Ext.data.Model'
fields: [
{Name: 'name', type: 'string'},
{Name: 'lastname', type: 'string'}
]
});

I have a store like this:

Ext.define ('MyApp.store.StoreUser', {
extend 'Ext.data.Store'
model: 'MyApp.model.User'
Proxy {
method: 'GET',
type: 'ajax'
url: 'User/GetInfo'
reader: {
type: 'json',
root: 'users'
}
}
autoload: true
});

I have a function in the server host as well (in a controller function):

JsonResult public GetInfo ()
{
var result = new
{
success = true,
info = new [] {
new {name = "Alejandro", lastname = "Mosquera"},
}
};

return Json (result, JsonRequestBehavior.AllowGet);
}

I have the following code:

var myUser = Ext.create ('MyApp.store.StoreUser');
How do I make a simple alert

alert (myUser.getAt(0).get('name')) / / This does not workThanks

thanks

tobiu
28 Nov 2011, 2:13 AM
the first thing i notice is:


autoload: true


which has to be:


autoLoad: true


so, i guess your store is not loaded yet.

alejandro-mosquera
28 Nov 2011, 6:27 AM
Hi, I've changed but does not work

lorezyra
6 Dec 2011, 3:58 PM
please encapsulate your code with the <code> (or <php>) tags... This makes the code fragments easier to read.