Ext Grid实例简易可编辑表格的多种实现方式
在Ext框架中,Grid对象是一个强大的工具。以下是几种常见的实现方式:
- 使用JSON数据源的可编辑Grid:
var grid = Ext.create('Ext.grid.Panel', {
store: {
fields: ['name', 'email'],
data: [
{ name: 'John', email: 'john@example.com' },
{ name: 'Jane', email: 'jane@example.com' }
]
},
columns: [
{ text: 'Name', dataIndex: 'name', editor: 'textfield' },
{ text: 'Email', dataIndex: 'email', editor: 'textfield' }
],
plugins: [Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })]
});
- 使用数组数据源的可编辑Grid:
var grid = Ext.create('Ext.grid.Panel', {
store: {
fields: ['id', 'product'],
data: [
[1, 'Book'],
[2, 'Pen']
]
},
columns: [
{ text: 'ID', dataIndex: 'id' },
{ text: 'Product', dataIndex: 'product', editor: 'textfield' }
],
plugins: [Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })]
});
- 从JSP动态获取数据的Grid:
var store = Ext.create('Ext.data.Store', {
fields: ['id', 'product'],
proxy: {
type: 'ajax',
url: 'data.jsp',
reader: {
type: 'json',
rootProperty: 'items'
}
},
autoLoad: true
});
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columns: [
{ text: 'ID', dataIndex: 'id' },
{ text: 'Product', dataIndex: 'product' }
]
});
这些Grid对象的实现方式展示了如何使用不同的数据源,简化了复杂表格的操作与编辑。
ext的grid简易例子
预估大小:302个文件
ext-all.css
140KB
ext-all-notheme.css
102KB
grid.css
6KB
tree.css
4KB
tabs.css
7KB
button.css
8KB
grid.css
11KB
menu.css
3KB
core.css
5KB
date-picker.css
5KB
510KB
文件大小:
评论区