{ field : 'bz', title : '备注', align : 'center', }如何在里面设置width宽度
时间: 2023-09-30 11:13:04 浏览: 74
你可以在该代码段中添加一个 `width` 属性并设置它的值,以指定列的宽度,例如:
```
{
field : 'bz',
title : '备注',
align : 'center',
width : 100 // 设置宽度为 100 像素
}
```
这将把 `bz` 列的宽度设置为 100 像素。你可以根据需要调整这个值。
相关问题
, cols: [[ { title: '编号', type: 'numbers', width:50, fixed: 'left' } , { field: 'river_status', title: '事件种类', width:150, align: 'center', , { field: 'event_no', title: '事件编号', width:280, align: 'center' } , { field: 'supervise_no', title: '督办单号', width:180, align: 'center' } , { field: 'describe', title: '事件内容', align: 'center' } , { field: 'supervise_topic', title: '督办标题', width:200, align: 'center' } , { field: 'create_time', title: '督办时间', width:150, align: 'center' } , { field: 'receive_user_name', title: '责任人员/单位',width:120, align: 'center' } , { field: 'user_name', title: '发起人员', width:90, align: 'center' } , { field: 'status', title: '状态', width:80, align: 'center', } , { toolbar: '#barDemo', title: '操作', width:160, align: 'center' } ]]river_status值为0展示河流事件值为1展示湖泊事件
根据您的描述,您想要在表格中展示不同类型的事件,其中 `river_status` 字段的值为0时展示河流事件,值为1时展示湖泊事件。根据您提供的代码片段,可以对 `field: 'river_status'` 进行修改,使用 formatter 函数来根据字段的值进行条件判断。
以下是修改后的代码示例:
```javascript
cols: [[
{ title: '编号', type: 'numbers', width: 50, fixed: 'left' },
{
field: 'river_status',
title: '事件种类',
width: 150,
align: 'center',
formatter: function(value, row, index) {
if (value === 0) {
return '河流事件';
} else if (value === 1) {
return '湖泊事件';
} else {
return '';
}
}
},
{ field: 'event_no', title: '事件编号', width: 280, align: 'center' },
{ field: 'supervise_no', title: '督办单号', width: 180, align: 'center' },
{ field: 'describe', title: '事件内容', align: 'center' },
{ field: 'supervise_topic', title: '督办标题', width: 200, align: 'center' },
{ field: 'create_time', title: '督办时间', width: 150, align: 'center' },
{ field: 'receive_user_name', title: '责任人员/单位', width: 120, align: 'center' },
{ field: 'user_name', title: '发起人员', width: 90, align: 'center' },
{ field: 'status', title: '状态', width: 80, align: 'center' },
{ toolbar: '#barDemo', title: '操作', width: 160, align: 'center' }
]]
```
在上述代码中,我们在 `field: 'river_status'` 的列中添加了 formatter 函数,根据字段的值进行条件判断,如果值为0,则返回"河流事件",如果值为1,则返回"湖泊事件",否则返回空字符串。
希望对您有所帮助!如果您还有其他问题,请随时提问。
解释一下 TableColumns: [ { field: '', checkbox: true, align: 'center', valign: 'middle', width: IdWidth }, { title: '等级', field: 'name', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: '类型', field: 'type', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: 'A', field: 'id', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: 'B', field: 'id', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: 'C', field: 'id', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: '目的', field: 'id', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt }, { title: '备注', field: 'remark', align: 'center', valign: 'middle', width: RemarkWidth }, ],
这是一个包含多个列的表格的定义,其中TableColumns是一个数组,每个元素表示一个表格列。每个列有不同的属性,如field表示该列对应的数据字段,title表示该列的标题,align表示该列的对齐方式(center表示居中对齐),valign表示该列的垂直对齐方式(middle表示居中对齐),width表示该列的宽度,formatter表示该列的格式化方式(formatTxt.NoTxt表示不格式化)。需要注意的是,第一个列中包含了一个checkbox,用来表示该行是否被选中。最后一个列是一个备注列,宽度较大,用来显示一些备注信息。