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>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐