如何禁用角度ui网格中特定列的大小调整

时间:2016-08-15 16:09:03

标签: javascript angularjs ui-grid

这是我的专栏

$scope.gridOpts = {
enableColumnResizing: true,
columnDefs : [
   {displayName:"Name",field:"name",width:'20%'},
   {displayName:"Gender",field:"gender",width:'*'},
   {displayName:"Company",field:"company",width:'60%'}
  ],
data: [
  { "name": "Ethel Price", "gender": "female", "company": "Enersol" },
  { "name": "Claudine Neal", "gender": "female", "company": "Sealoud" },
  { "name": "Beryl Rice", "gender": "female", "company": "Velity" },
  { "name": "Wilder Gonzales", "gender": "male", "company": "Geekko" }
]};

我想在最后一列(公司)上禁用大小调整,当前解决方案可以正常工作,但在窗口缩小到某个点时开始截断并添加省略号。

1 个答案:

答案 0 :(得分:1)

要禁用最后一列调整大小,请将最后一列属性enableColumnResizing设置为false

columnDefs : [
       {displayName:"Name",field:"name",width:'20%'},
       {displayName:"Gender",field:"gender",width:'*'},       {displayName:"Company",field:"company",width:'60%',enableColumnResizing:false}
      ]

调整大小时添加省略号是预期的行为。

如果要控制该行为,则必须将minWidth属性设置为列定义。