我有一个带网格的表格。网格值从商店加载,但商店将在按钮点击事件后加载。所以问题是网格试图在商店加载之前加载值。
Ext.onReady(function() {
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');
Ext.define('userList', {
extend: 'Ext.data.Model',
fields: [
{
name: 'id',
mapping: 'id'
},
{
name: 'name',
mapping: 'name'
}
]
});
store = Ext.create('Ext.data.Store', {
model: 'userList',
autoLoad: true,
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'Users'
}
}
});
var searchUsers = new Ext.FormPanel({
renderTo: "searchUsers",
frame: true,
title: 'Search Users',
bodyStyle: 'padding:5px',
width: 900,
items: [
{
xtype:'textfield',
fieldLabel: 'Username',
name: 'userName'
},
{
xtype: 'button',
text: 'Search',
listeners: {
click: function() {
store.getProxy().url = url+'/lochweb/loch/users/getUser';
store.load();
}
}
},
grid = Ext.create('Ext.grid.Panel', {
id: 'userGrid',
width: 900,
height: 300,
frame: true,
store: store,
iconCls: 'icon-user',
columns: [
{
text: 'ID',
width: 40,
sortable: true,
dataIndex: 'id'
},
{
text: 'FirstName',
flex: 1,
sortable: true,
dataIndex: 'firstName',
field: {
xtype: 'textfield'
}
},
{
text: 'LastName',
flex: 1,
sortable: true,
dataIndex: 'lastName',
field: {
xtype: 'textfield'
}
}
]
})
]
});
var win = new Ext.Window({
layout: 'fit',
closable: false,
resizable: true,
plain: true,
border: false,
items: [searchUsers]
});
win.show();
});
按钮点击事件后还有其他方法加载网格吗?
答案 0 :(得分:2)
只需将'autoLoad:false'设置到商店中即可。