一:js部分
1.先定義model
Ext.define('ICeData', {
extend: 'Ext.data.Model',
fields: ['Author', 'Title', 'Manufacturer', 'ProductGroup']
});
2.創建store
var store = new Ext.data.ArrayStore({
model: 'ICeData',
proxy: {
type: 'ajax',
url: appPath + 'Getjson', //url對應.NET控制器的動作
reader: {
type: 'json'
}
},
fields: [//這裏要和model的fields對應
{ name: 'Author' },
{ name: 'Title', type: 'float' },
{ name: 'Manufacturer', type: 'float' },
{ name: 'ProductGroup', type: 'float' }
]
});
3.爲grid控件的 store屬性賦值:
store: store
4.調用store的load方法
store.load();
二:C#部分
1,建立一個簡單類:
public class Database
{ //屬性名字要和js的fields名字對應
public string Author { get; set; }
public double Title { get; set; }
public double Manufacturer { get; set; }
public double ProductGroup { get; set; }
public Database(string Author, double Title, double Manufacturer, double ProductGroup)
{
this.Author = Author;
this.Title = Title;
this.Manufacturer = Manufacturer;
this.ProductGroup = ProductGroup;
}
}