我设置了一列为可编辑
var colM = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(), sm,
{header :'商品名称',dataIndex:'productName'}
,{header :'颜色',dataIndex:'pcolor'}
,{header :'尺码',dataIndex:'psize'}
,{header :'录入方式',dataIndex:'createBarcodeType',renderer:showCreateBarcodeType}
,{header :'条码',dataIndex:'barCode',editor : new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank : false}))}
]);
这个条码我想根据录入方式 0为可编辑,1为不可编辑的单元格,请问应该怎样做才可以,谢谢!
2条回答 默认 最新
- iteye_7115 2012-08-21 02:04关注
麻烦下次问问题的话,把代码提供全些
[code="java"] <br> Ext.onReady(function(){<br> var sm = new Ext.grid.RowSelectionModel({singleSelect : true});<br> //grid列<br> var cm = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(), sm, <br> {header :'商品名称',dataIndex:'productName'} <br> ,{header :'颜色',dataIndex:'pcolor'} <br> ,{header :'尺码',dataIndex:'psize'} <br> ,{header :'录入方式',dataIndex:'createBarcodeType'} <br> ,{header :'条码',dataIndex:'barCode',editor : new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank : false}))} <br> ]); <br> //测试数据<br> var data = [<br> ['Coco','red','120','1','12321323'],<br> ['dfkls','blue','120','0','12321323'],<br> ['ce3dfe','red','120','1','12321323'],<br> ['Cosdfco','yellow','120','1','12321323'],<br> ['swr','red','120','0','12321323']<br> ];<br> //数据存储器<br> var ds = new Ext.data.Store({<br> proxy:new Ext.data.MemoryProxy(data),<br> reader:new Ext.data.ArrayReader({},[<br> {name:'productName'},<br> {name:'pcolor'},<br> {name:'psize'},<br> {name:'createBarcodeType'},<br> {name:'barCode'}<br> ])<br> });</p> <pre><code> var grid=new Ext.grid.EditorGridPanel({ title:'测试列表', //el:'grid', renderTo:'grid', width:800, height:300, autoScroll:true, store:ds, cm:cm, sm:sm, listeners:{ 'beforeedit':function(o){ var createBarcodeType = o.record.get('createBarcodeType'); if(createBarcodeType == '1') return true; else return false; } } }); ds.load(); }); </script>[/code] </code></pre> <p>里面核心的思路就是在EditorGridPanel上加beforeedit监听事件<br> [code="java"]<br> 'beforeedit':function(o){<br> var createBarcodeType = o.record.get('createBarcodeType');<br> if(createBarcodeType == '1')<br> return true;<br> else<br> return false;<br> }<br> [/code]</p> <p>[quote]<br> [b]beforeedit[/b] : ( Object e ) <br> Fires before cell editing is triggered. The edit event object has the following properties </p> <p>grid - This grid <br> record - The record being edited <br> field - The field name being edited <br> value - The value for the field being edited. <br> row - The grid row index <br> column - The grid column index <br> cancel - Set this to true to cancel the edit or return false from your handler<br> [/quote]</p>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 python排课代码读写xlsx表格出现bug
- ¥15 KeiI中头文件找不到怎么解决
- ¥15 QT6将音频采样数据转PCM
- ¥15 本地安装org.Hs.eg.dby一直这样的图片报错如何解决?
- ¥15 下面三个文件分别是OFDM波形的数据,我的思路公式和我写的成像算法代码,有没有人能帮我改一改,如何解决?
- ¥15 Ubuntu打开gazebo模型调不出来,如何解决?
- ¥100 有chang请一位会arm和dsp的朋友解读一个工程
- ¥50 求代做一个阿里云百炼的小实验
- ¥15 查询优化:A表100000行,B表2000 行,内存页大小只有20页,运行时3页,设计两个表等值连接的最简单的算法
- ¥15 led数码显示控制(标签-流程图)