爱吃饭的 2019-01-11 09:21 采纳率: 0%
浏览 164

extjs表单编辑插件读取xml文件失败,求帮看原因

<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>
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题