Javascript 从Ext JS 2.0.2中的EditorGridPanel中删除行

Javascript 从Ext JS 2.0.2中的EditorGridPanel中删除行,javascript,extjs,Javascript,Extjs,我是Ext JS新手,需要更新一个旧应用程序。EditorGridPanel有一个“添加”按钮,可以正常工作。但是,我需要添加一个“删除”按钮,从网格中删除该行。下面是网格的代码。谢谢你的帮助 /*==== INVOICE DATA START =======================================================*/ var iLineItemCM = new Ext.grid.ColumnModel([ {id:'i_lin

我是Ext JS新手,需要更新一个旧应用程序。EditorGridPanel有一个“添加”按钮,可以正常工作。但是,我需要添加一个“删除”按钮,从网格中删除该行。下面是网格的代码。谢谢你的帮助

 /*==== INVOICE DATA START =======================================================*/
    var iLineItemCM = new Ext.grid.ColumnModel([
         {id:'i_line_item_name', header: "Line Item Name", dataIndex:     'i_line_item_name', width: 280,
           editor: new Ext.form.TextField({allowBlank: false})}
        ,{header: "Amount", dataIndex: 'i_line_item_amt', width: 80, align: 'right', renderer: 'usMoney',
         editor: new Ext.form.NumberField({
               allowBlank: false,
               allowNegative: false,
               maxValue: 100000
           })}
        ]);

    var iLineItemRec =
        new Ext.data.Record.create([
            {name: 'i_line_item_name'    ,mapping: 'i_line_item_name'  ,type: 'string'}
           ,{name: 'i_line_item_amt'     ,mapping: 'i_line_item_amt'   ,type: 'string'}
         ]);

    var iLineItemStore = new Ext.data.Store({
        url: '',
        reader: new Ext.data.JsonReader({
               root: 'rows'
         },
           iLineItemRec
        )
    });

    var iLineItemGrid = new Ext.grid.EditorGridPanel({
        store: iLineItemStore,
        cm: iLineItemCM,
        width: 'auto',
        height: 'auto',
        //title:'Edit Plants?',
        frame:false,
        //plugins:checkColumn,
        clicksToEdit:1,
        viewConfig: {
            //forceFit: true,
            autoFit:true
      },
      id: 'iLineItemStore',
        tbar: [{
            text: 'Add Line Item',
            handler : function(){
               var r = new iLineItemRec({
                   i_line_item_name: '',
                    i_line_item_amt: ''
               });
                iLineItemGrid.stopEditing();
               iLineItemStore.insert(0, r);
               iLineItemGrid.startEditing(0, 0);
          }
      }]
    });

 ///////////////////

从单元格选择模型的文档中:

单元模型被指定为默认值

getSelectedCell( ) : Array
Returns the currently selected cell's row and column indexes as an array (e.g., [0, 0]).
所以。。。差不多

 { text: 'Remove', 
  tooltip:'Remove the selected item',
  handler: function(){ 
  iLineItemGrid.stopEditing();
  var r = iLineItemGrid.getSelectionModel().getSelectedCell();
  iLineItemStore.removeAt(r[1]); } }

从单元格选择模型的文档中:

单元模型被指定为默认值

getSelectedCell( ) : Array
Returns the currently selected cell's row and column indexes as an array (e.g., [0, 0]).
所以。。。差不多

 { text: 'Remove', 
  tooltip:'Remove the selected item',
  handler: function(){ 
  iLineItemGrid.stopEditing();
  var r = iLineItemGrid.getSelectionModel().getSelectedCell();
  iLineItemStore.removeAt(r[1]); } }

您好,我已经尝试过这个代码,但它不起作用。{text:'Remove',工具提示:'Remove the selected item',handler:function(){iLineItemGrid.stopEditing();var r=iLineItemGrid.getSelectionModel().getSelected();iLineItemStore.removeAt(r[0]);}}您好,我已经尝试过这个代码,但它不起作用。{text:'Remove',工具提示:'Remove the selected item',处理程序:function(){iLineItemGrid.stopEditing();var r=iLineItemGrid.getSelectionModel().getSelected();iLineItemStore.removeAt(r[0]);}