1

我想从树中拖出一个叶子节点并将其放到编辑器网格单元格中,这样单元格就会将叶子的文本作为数据。

我正在使用编辑器网格,在其中动态添加行。

下面是我的代码

        Ext.define('Field_model', {<br>
            extend: 'Ext.data.Model',<br>
            fields: [<br>

                        {name: 'select_field'},
                        {name: 'select_function'},
                        {name: 'symbolic_name'}
                ]
        });<br>
        `var cellEditing_field = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1});`

        `var field_store = Ext.create('Ext.data.JsonStore', {
                    model: 'Field_model',
                    data:[
                                         {
                                           "select_field":"click toedit...",
                                           "select_function":"click to select...",
                                           "symbolic_name":"click to edit..."
                                         }
                                        ]
                    });`

        var Field_grid = Ext.create('ListGrid', {<br>
            store: field_store,<br>
            columns: [{<br>
                header: 'Add/Delete',<br>
                xtype: 'actioncolumn',<br>
                width:130,<br>
                sortable: false,<br>
                items: [{<br>
                        icon: 'add.png',<br>
                        tooltip: 'Add',<br>
                         handler : function(){<br>
                                                var r = Ext.create('Field_model', {<br>
                                                    select_field: 'click to edit...',<br>
                                                    select_function: 'click to select...',<br>
                                                    symbolic_name: 'click to edit...'<br>
                                                });<br>                             field_store.insert(0, r);<br>
                                                cellEditing_field.startEditByPosition({row: 0, column: 0});<br>
            }<br>
                        },{<br>
                        icon: 'delete.png',<br>
                        tooltip: 'Delete',<br>
                        handler: function(grid, rowIndex, colIndex) {<br>
                            if(grid.getStore().data.length==1)<br>
                            {<br>
                            alert('cannot delete this record');<br>
                            }
                            else<br>
                            {<br>
                            field_store.removeAt(rowIndex);<br>
                            }<br>
                            }<br>
                    }]<br>
            },{<br>
                header: 'Select Field',<br>
                dataIndex: 'select_field',<br>
                width:130,<br>
                editor: {<br>
                        xtype:'textfield'<br>

                    }
            }, {
                header: 'Function',
                dataIndex: 'select_function',
                width: 130,
                editor: {
                            xtype:'combobox',
                            triggerAction:'all',
                            mode:'local', 
                            store: ['Distinct','Sum','Count']
                          }
            }, {
                header: 'Symbolic Name',
                dataIndex: 'symbolic_name',
                width: 130,
                editor: {
                        xtype:'textfield'

                    }
            }],
            selModel: {
                selType: 'cellmodel'
            },
            plugins: [cellEditing_field]
        });

以上是我正在使用的网格

提前致谢

4

0 回答 0