Sencha JsonStore和ASP.NET MVC3

时间:2011-03-30 02:44:08

标签: asp.net-mvc-3 sencha-touch

您好: 我试图在sencha触摸表单中生成一个下拉列表,其中数据从控制器返回如下:

   //location controller action
    public ActionResult locationList()
    {
        List<Location> locations = DB.Locations.ToList();
        return Json(new { data = locations }, JsonRequestBehavior.AllowGet);
    }

sencha javascript config:

    Ext.regModel('Location', {
        fields: [
            { name: 'LocationId', type: 'int' },
            { name: 'LocationName', type: 'string' },
            { name: 'LocationDescription', type: 'string' }
        ]
    });

    var locationStore = new Ext.data.JsonStore({
        model: 'Location',
        proxy: {
            type: 'ajax',
            url: '/location/locationList',
            fields: [
                'LocationId',
                'LocationName',
                'LocationDescription'
            ],
            reader: {
                type: 'json',
                root: 'data'
            },
            actionMethods: {
                read: 'POST'
            }
        }
    }).load();

表格项目:

        items: [
            {
                xtype: 'selectfield',
                name: 'DepartLocationId',
                label: 'Depart',
                valueField: 'LocationId',
                displayField: 'LocationName',
                store: locationStore
            }, 
            ..........
        ]

sencha触摸表单中的下拉列表是空的,有什么想法吗?

0 个答案:

没有答案