Easyui的propertygrid下拉框值回显
HTML示例代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PropertyGrid Combobox</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="./themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="./themes/icon.css">
<script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript" src="./jquery.easyui.min.js"></script>
<script>
$(function(){
var data = {"total":4,"rows":[
{"code":"Name", "name":"Name", "value":"Bill Smith","group":"ID Settings","editor":"text"},
{"code":"Address", "name":"Address","value":"","group":"ID Settings","editor":"text"},
{"code":"SSN", "name":"SSN","value":"123-456-7890","group":"ID Settings","editor":"text"},
{"code":"Email", "name":"Email","value":"bill@gmail.com","group":"Marketing Settings","editor":{"type":"validatebox","options":{"validType":"email"}}},
{"code":"status", "name":"状态","value":"1","group":"Marketing Settings","editor":{type:"combobox",
options:{
editable: false,
valueField: "value",
textField: "text",
data: [{value: "0", text: "显示"}, {value: "1", text: "隐藏"}]
}}}
]};
$('#pg').propertygrid({
columns: [
[
{ field:'name', title:'Name', width:500, sortable:true },
{ field:'value', title:'Value', width:400 ,
formatter: function (value,rowData,rowIndex) {
if (rowData.code=="status") {
if (value == '0') {
return "显示";
} else {
return "隐藏";
}
} else {
return value;
}
}
}
]
],
showGroup: true,
scrollbarSize: 0,
data: data
});
})
function getData(){
const rows = $('#pg').propertygrid('getRows');
console.table(rows );
}
</script>
</head>
<body>
<a href="javascript:void(0)" onclick="getData()">button</a>
<table id="pg" style="width:300px"></table>
</body>
</html>
效果图
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201201192741266.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NvbmdkYW5jZXI=,size_16,color_FFFFFF,t_70)