我正在使用 Extjs 6 构建网格视图。这是我的商店:schedule.js
Ext.define('schedulewise.store.schedule.Schedule', {
extend: 'Ext.data.Store',
alias: 'store.Schedule',
requires: [
'schedulewise.utils.Config'
],
model: 'schedulewise.model.schedule.Schedule',
autoLoad: true,
proxy: {
type: 'rest',
url: 'http://127.0.0.1:8080/' + schedulewise.utils.Config.projectName + '/rest/cserver/dto/schedule/allInfo?request=loadSchedule',
useDefaultXhrHeader: false,
reader: {
type: 'json'
},
writer: {
type: 'json'
}
}
这是我的视图模型:ScheduleModel.js
Ext.define('schedulewise.view.schedule.ScheduleModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.ScheduleModel',
stores: {
Schedule: {
type:'Schedule'
}
},
data:{
title:'Schedules'
}
});
这是我的观点:
Ext.define("schedulewise.view.schedule.MainPanel", {
extend: 'Ext.grid.Panel',
xtype: 'MainPanel',
requires: [
'schedulewise.utils.Config'
],
layout: 'fit',
region: 'center',
controller: 'ScheduleController',
viewModel: 'ScheduleModel',
bind: {
store: '{Schedule}',
title:'{title}'
},
columns: [
{
text: 'Name',
dataIndex: 'scheduleName',
resizable: false,
hideable: false,
sortable: false,
flex: 25 / 100
},
{
text: 'lastestVersion',
dataIndex: 'lastestVersion',
resizable: false,
hideable: false,
sortable: false,
flex: 25 / 100
},
{
text: 'currentVersion',
dataIndex: 'lastestVersion',
resizable: false,
hideable: false,
sortable: false,
flex: 25 / 100
},
{
text: 'date range',
dataIndex: 'scheduleRange',
resizable: false,
hideable: false,
sortable: false,
flex: 25 / 100
}
]
});
我发现加载视图时,Store 总是请求两次。我不知道为什么? 截屏