<script type="text/javascript">
var cellModel = Ext.create('Ext.data.Model', {
id: 'cellModel',
fields: [
// the 'name' below matches the tag name to read, except 'availDate'
// which is mapped to the tag 'availability'
{ name: 'common', type: 'string' },
{ name: 'botanical', type: 'string' },
{ name: 'light', type: 'string' },
{ name: 'price', type: 'float' },
// dates can be automatically converted by specifying dateFormat
{ name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y' },
{ name: 'indoor', type: 'bool' }
]
});
var celleditGrid = Ext.create('Ext.grid.Panel', {
id: 'celleditGrid',
title: 'Edit Plants',
frame: true,
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
store: new Ext.data.Store({
// destroy the store if the grid is destroyed
autoDestroy: true,
model: cellModel,
proxy: {
type: 'ajax',
// load remote data using HTTP
url: 'XML/plants.xml',
// specify a XmlReader (coincides with the XML format of the returned data)
reader: {
type: 'xml',
// records will have a 'plant' tag
record: 'plant'
}
},
sorters: [{
property: 'common',
direction: 'ASC'
}],
autoLoad: true
}),
selType: 'cellmodel',
columns: [{
header: 'Common Name',
dataIndex: 'common',
flex: 1,
editor: {
allowBlank: false
}
}, {
header: 'Light',
dataIndex: 'light',
width: 130,
editor: new Ext.form.field.ComboBox({
typeAhead: true,
triggerAction: 'all',
store: [
['Shade', 'Shade'],
['Mostly Shady', 'Mostly Shady'],
['Sun or Shade', 'Sun or Shade'],
['Mostly Sunny', 'Mostly Sunny'],
['Sunny', 'Sunny']
]
})
}, {
header: 'Price',
dataIndex: 'price',
width: 70,
align: 'right',
formatter: 'usMoney',
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 100000
}
}, {
header: 'Available',
dataIndex: 'availDate',
xtype: 'datecolumn',
width: 95,
format: 'M d, Y',
editor: {
xtype: 'datefield',
format: 'm/d/y',
minValue: '01/01/06',
disabledDays: [0, 6],
disabledDaysText: 'Plants are not available on the weekends'
}
}, {
xtype: 'checkcolumn',
header: 'Indoor?',
dataIndex: 'indoor',
width: 90,
stopSelection: false
}, {
xtype: 'actioncolumn',
width: 30,
sortable: false,
menuDisabled: true,
items: [{
icon: 'resources/images/icons/fam/delete.gif',
tooltip: 'Delete Plant',
scope: this,
handler: onRemoveClick
}]
}],
selModel: {
selType: 'cellmodel'
},
tbar: [{
text: 'Add Plant',
scope: this,
handler: onAddClick
}]
});
var loadStore = function () {
this.getStore().load();
}
var onAddClick = function () {
// Create a model instance
var rec = new KitchenSink.model.grid.Plant({
common: '',
light: 'Mostly Shady',
price: 0,
availDate: Ext.Date.clearTime(new Date()),
indoor: false
});
this.getStore().insert(0, rec);
this.cellEditing.startEditByPosition({
row: 0,
column: 0
});
}
var onRemoveClick = function (grid, rowIndex) {
this.getStore().removeAt(rowIndex);
}
var onEditComplete = function (editor, context) {
this.getView().focusRow(context.record);
}
Ext.onReady(function () {
new Ext.Viewport({
layout: 'border',
items: [
{ border: 1, id: 'TT', height: 600, layout: 'fit', items: [celleditGrid], autoScroll: false, region: 'north' }
]
});
});
</script>
extjs表单编辑插件读取xml文件失败,求帮看原因
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
0条回答 默认 最新
悬赏问题
- ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
- ¥20 易康econgnition精度验证
- ¥15 msix packaging tool打包问题
- ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
- ¥15 python的qt5界面
- ¥15 无线电能传输系统MATLAB仿真问题
- ¥50 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致