用easyui来设置 如果值是1这个 {field: 'sealStatus', width: 80, align: 'center', title: '印章状态'},字段的显示成禁用
时间: 2024-01-01 13:03:40 浏览: 31
可以使用easyui的formatter属性来设置字段的显示样式。在formatter函数中判断字段值是否为1,如果是1则返回禁用样式,否则返回原始值。具体代码如下:
```javascript
{
field: 'sealStatus',
width: 80,
align: 'center',
title: '印章状态',
formatter: function(value){
if(value === 1){
return "<span style='color:red'>禁用</span>";
} else {
return value;
}
}
}
```
在上面的代码中,如果字段的值为1,则使用红色文本显示为"禁用",否则显示原始值。你可以根据需要修改样式和显示内容。
相关问题
easyui中 field: 'applicationApt', title: '申请部门', width: 100, 设置如果value是10011 显示事业部怎么设置
如果你想在 EasyUI 的表格中,将字段值为 10011 显示为 "事业部",可以使用 `formatter` 函数来实现。以下是修改后的代码示例:
```javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Excel-like Table</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easyui/dist/themes/default/easyui.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easyui/dist/themes/icon.css">
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/easyui/dist/jquery.easyui.min.js"></script>
<style>
#dg {
width: 100%;
height: 400px;
}
</style>
</head>
<body>
<table id="dg" class="easyui-datagrid"
data-options="
url: 'get_data.php', // 替换成获取数据的 URL
singleSelect: true,
fitColumns: true,
toolbar: '#toolbar',
pagination: true,
pageSize: 20,
pageList: [10,20,30,40,50],
rownumbers: true,
striped: true,
columns: [[
{field:'id',title:'序号',width:60},
{field:'requestNumber',title:'申请单号',width:100},
{field:'documentName',title:'用印文件名称',width:150},
{field:'copyCount',title:'用印份数',width:80},
{field:'department',title:'申请部门',width:100, formatter: formatDepartment},
{field:'applicant',title:'申请人',width:100},
{field:'requestDate',title:'申请日期',width:100}
]]
">
</table>
<div id="toolbar">
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true">Add</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true">Edit</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true">Remove</a>
</div>
<script>
function formatDepartment(value) {
if (value === '10011') {
return '事业部';
}
return value;
}
</script>
</body>
</html>
```
在上述代码中,我们添加了一个名为 `formatDepartment` 的函数,并将其作为 `formatter` 函数指定给了申请部门的列。在 `formatDepartment` 函数中,我们检查字段值是否为 `10011`,如果是,则返回字符串 `'事业部'`,否则返回原始值。这样就能实现将字段值为 `10011` 的显示为 `'事业部'`。
{field:'status',title:'Status',width:50,align:'center', editor:{ type:'checkbox', options:{ on: "true", off: "false" } } }, options未生效
根据你提供的代码,我发现你在使用easyui的datagrid中的editor时,options未生效。这可能是由于你没有正确设置editor的值。下面是一个示例,展示了如何在easyui的datagrid中使用checkbox editor,并正确设置options:
```
{field:'status',title:'Status',width:50,align:'center', editor:{
type:'checkbox',
options:{
on:'true',
off:'false'
}
}}
```
请注意,options应该是一个对象,并且包含两个属性:on和off,它们分别对应选中和未选中状态的值。请确保在您的代码中正确设置这些值。如果这些仍然无效,可以检查你是否正确引入了easyui的相关脚本和样式文件。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)