wuguangbiao518 2010-07-29 10:59 采纳率: 0%
浏览 403
已采纳

EditorGridPanel报错:Index or size is negative or greater than the allowed amount

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



WindowTabPanelGrid.html
Ext.onReady(function(){ Ext.BLANK_IMAGE_URL = '../ext-2.0.2/resources/images/default/s.gif'; var myDataPress = { records : [ { name : "A + B = C"}, { name : "A + C = D"}, { name : "D + E = F"}, { name : "B + G = K"}, { name : "T + E = L"}, { name : "S + W = P"}, { name : "Q + V = O"}, { name : "R + N = D"}, { name : "Q + S = A"} ] }; var fields = [ {name: 'name', mapping : 'name'} ]; var Record = Ext.data.Record.create([ {name: 'name', type: 'string'} ]); var gridStore = new Ext.data.JsonStore({ fields : fields, data : myDataPress, root : 'records' }); var cols = [ {id:'name', header:'公式',width:100, sortable: true, dataIndex: 'name', editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))} ]; var grid = new Ext.grid.EditorGridPanel({ ddGroup : 'gridDDGroup', store : gridStore, columns : cols, enableDragDrop : true, stripeRows : true, autoExpandColumn :'name', width : 150, region : 'west', selModel : new Ext.grid.RowSelectionModel({singleSelect : true}), bbar : new Ext.Toolbar(['-', { text: '添加', handler: function(){ var initValue = {name:''}; var p = new Record(initValue); grid.stopEditing(); gridStore.insert(0, p); grid.startEditing(0, 0); p.dirty = true; p.modified = initValue; if(gridStore.modified.indexOf(p) == -1){ gridStore.modified.push(p); } } }, '-', { text: '删除', handler: function(){ Ext.Msg.confirm('信息', '确定要删除?', function(btn){ if (btn == 'yes') { var sm = grid.getSelectionModel();// 这几行会出错。 var record = sm.getSelected();// 这几行会出错。 store.remove(record);// 这几行会出错。 } }); } }, '-', { text: '保存', handler: function(){ alert('暂时还没有实现保存功能!!'); } }, '-']) }); var textField1 = new Ext.form.TextField({ fieldLabel : '公式', name : 'name', width :181, readOnly : true }); var formPanel = new Ext.form.FormPanel({ region : 'center', bodyStyle : 'padding:10px; background-color: #DFE8F6', bodyBorder :false, labelWidth : 100, width : 350, defaults:{ labelStyle:'text-align:right;' }, items : [ textField1, { xtype:'datefield', width:181, fieldLabel:'时间' }, { xtype:'combo', fieldLabel:'其他', store: new Ext.data.SimpleStore({ fields: ['countryCode'], data: [ ['US'], ['DE'], ['FR'] ] }), valueField: 'countryCode', displayField: 'countryCode', triggerAction: 'all', editable: false, mode: 'local' } ], buttons:[ { text:'检验', handler:function(){ alert('检验'); } }, { text:'重置', handler:function(){ alert('重置'); } } ] }); var displayPanel = new Ext.Panel({ width : 500, height : 300, layout : 'border', items : [ grid, formPanel ] }); var myData = [ ['A + B = Y', '07/30/2010', '未通过'], ['A + B = Y', '09/21/2010', '通过'], ['D + B = E', '07/05/2010', '通过'], ['T + R = K', '05/25/2005', '未通过'] ]; var store = new Ext.data.SimpleStore({ fields: [ {name: 'expression'}, {name: 'time'}, {name: 'pass'} ] }); store.loadData(myData); var cm = new Ext.grid.ColumnModel([ {header:'公式', dataIndex:'expression'}, {header:'时间', dataIndex:'time'}, {id:'pass', header:'是否通过', renderer:function(value){ if(value == '通过'){ return '<span style="color:green;">通过</span>' } else{ return '<span style="color:red;">未通过</span>' } }, dataIndex:'pass'} ]); Ext.MyGrid =new Ext.grid.GridPanel({ bodyBorder:true, store:store, cm:cm, autoExpandColumn:'pass' }); Ext.MyPanel = new Ext.Panel({ buttonAlign:'center', bodyBorder:false, layout:'form', bodyStyle:'padding:50px 20px;', defaults:{ labelStyle:'text-align:right;' }, items:[ { xtype:'textfield', fieldLabel:'公式' }, { xtype:'datefield', fieldLabel:'时间' }, { xtype:'combo', fieldLabel:'其他', store: new Ext.data.SimpleStore({ fields: ['countryCode'], data: [ ['US'], ['DE'], ['FR'] ] }), valueField: 'countryCode', displayField: 'countryCode', triggerAction: 'all', editable: false, mode: 'local' } ], buttons:[ { text:'检验', handler:function(){ alert('检验'); } }, { text:'重置', handler:function(){ alert('重置'); } } ] }); Ext.MyTab = new Ext.TabPanel({ autoTabs:true, activeTab:0, deferredRender:false, border:false, items:[ { title:'交验', id:'tab1', layout:'fit', width:500, height:300, items:displayPanel }, { title:'查看', id:'tab2', layout:'fit', width:500, height:300, items:Ext.MyGrid } ] }); Ext.MyWindow = new Ext.Window({ title:'指标校验', layout:'fit', width:500, height:300, closeAction:'hide', plain: true, items: Ext.MyTab }); Ext.MyWindow.render(Ext.getBody()); Ext.MyWindow.show(); var formPanelDropTargetEl = formPanel.body.dom; var formPanelDropTarget = new Ext.dd.DropTarget(formPanelDropTargetEl, { ddGroup : 'gridDDGroup', notifyEnter : function(ddSource, e, data) { //Add some flare to invite drop. //formPanel.body.stopFx(); formPanel.body.highlight(); }, notifyDrop : function(ddSource, e, data){ var selectedRecord = ddSource.dragData.selections[0]; formPanel.getForm().loadRecord(selectedRecord); return(true); } }); }); .x-date-middle { padding-top:2px;padding-bottom:2px; width:130px; /* FF3 */ }



[color=red]点击删除后 ,弹出的点yes ,就会出错!!望赐教!![/color]

  • 写回答

1条回答 默认 最新

  • works001 2010-08-04 10:18
    关注

    我用ext3.2测试的 代码没改 没有你说的问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥20 OPENVPN连接问题