Extjs 4 解决 grid + checkboxmodel+rowediting 对齐的bug

在Extjs 4.0中,实现 行选择、行编辑很简单,但是checkboxmodel 和 rowediting插件组合存在一个对齐的bug。

在线demo:http://extjshelp.sinaapp.com/rowedit/

 

grid + checkboxmodel 的显示效果如下:



 双击编辑一行:



 注意到,编辑器没有和grid表头对齐。原因就是我们加了一列checkbox。这是Extjs 4.0 的bug,rowediting 插件和checkboxmodel组件之间没有配合好。

解决方法,让item项的编辑器往右边"挤一挤":

 

{text:'Item',dataIndex:'item',editor:{ margin:'0 0 0 22 ' }},

现在看起来整齐了:


 完整的代码:

 

Ext.onReady(function(){
	var store = {
		type:'array',
		fields:["item","price"],
		data:[
			["Steve Bible",0.99],
			["Steve Bible",0.99],
			["Steve Bible",0.99],
			["Steve Bible",0.99]
		]
	}
	var checkmodel = Ext.create('Ext.selection.CheckboxModel')
	var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
		clicksToMoveEditor: 2,
		autoCancel: false
        })
	
	var grid = Ext.create("Ext.grid.Panel",{
		store:store,
		plugins: [rowEditing],
		selModel:checkmodel,
		columns:[
			{text:'Item',dataIndex:'item',editor:{ margin:'0 0 0 22 ' }},
			{text:'Price',dataIndex:'price',editor:{type:'numberfield'}},
		],
		region:'center'
	})
	Ext.create('Ext.container.Viewport',{
		layout:'border',
		items:[
			grid
		]
	})
})

 

 

<html>
	<head>
	<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">
	<script type="text/javascript" src="../extjs/ext-all.js"></script>
	<script type="text/javascript" src="app.js"></script>
	</head>
	<body>
	</body>
</html>
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值