{field: 'expenseName',title: "费用名称",width:100, formatter:function(value,row){ return row.value; }, editor:{ type:'combobox', options:{ valueField:'key', textField:'value', data:ExpenseList, required:true } } },选择后关闭editor页面不显示值
时间: 2024-02-10 07:35:02 浏览: 23
这个问题的原因可能是因为在formatter函数中,使用了错误的属性名或者没有返回正确的值。你可以检查一下代码,确保使用的是正确的属性名,并且formatter函数返回的值是正确的。
另外,你也可以检查一下editor页面的关闭事件,确保在关闭页面时将选择的值正确地赋值给了相应的属性。如果还是无法解决问题,可以提供更多的代码和错误信息,以便我更好地帮助你解决问题。
相关问题
columns:[[ { field: 'showCheckboxWithId', checkbox: true, formatter: function (value, row, index) { return row.id } }, datagrid sppend后根据不同属性禁用checkbox
在EasyUI的DataGrid中,我们可以通过定义列的formatter函数来实现根据不同属性值来禁用某些单元格中的复选框。具体来说,我们可以在formatter函数中返回一个`<input>`标签,并给它添加一个`disabled`属性。然后,我们可以使用jQuery的`each()`函数遍历DataGrid的所有行和列,并找到我们想要禁用的单元格中的复选框,并将它的`<input>`标签设置为禁用状态。
在你给出的示例代码中,我们可以在`showCheckboxWithId`列的formatter函数中,通过判断`row`的某个属性值来决定是否禁用复选框。具体来说,我们可以在formatter函数中返回一个`<input>`标签,并给它添加一个`disabled`属性。然后,我们可以根据`row`的某个属性值来判断是否禁用该复选框。
下面是一个示例代码:
```javascript
// 定义DataGrid的columns
var columns = [[
{field:'showCheckboxWithId',title:'',width:50,checkbox:true, formatter: function (value,row,index) {
if (row.someProperty === 'someValue') {
// 如果满足某个条件,则禁用复选框
return '<input type="checkbox" disabled="disabled">';
} else {
// 否则正常显示复选框
return '<input type="checkbox">';
}
}},
{field:'id',title:'ID',width:100},
{field:'name',title:'Name',width:100},
{field:'age',title:'Age',width:100}
]];
// 在DataGrid中添加数据后,禁用满足条件的复选框
$('#dg').datagrid('appendRow',{
id:1,
name:'John',
age:20,
someProperty: 'someValue'
}).datagrid('appendRow',{
id:2,
name:'Jane',
age:16,
someProperty: 'someOtherValue'
}).datagrid('getPanel').find('input[type="checkbox"][disabled="disabled"]').each(function(){
$(this).closest('td').css('opacity', '0.5');
});
```
在上面的代码中,我们定义了一个包含四列的DataGrid,其中`showCheckboxWithId`列是一个带有复选框的列。在这个列的formatter函数中,我们判断行的`someProperty`属性是否等于`someValue`,如果满足,则返回一个禁用状态的`<input>`标签。
接着,我们向DataGrid中添加了两行数据,并且使用`getPanel()`函数获取DataGrid的面板,然后使用`find()`函数查找所有禁用状态的复选框,并使用`each()`函数遍历它们,并将它们的父元素`<td>`的不透明度设置为0.5,从而禁用它们。
columns: [[ { field: 'showCheckboxWithId', checkbox: true, formatter: function (value, row, index) { return row.id } }, {field: 'id',title: "id",hidden: true}, {field: 'productionBarCode',title: "提单号/运单号",width:150}, {field: 'salesBarCode',title: "一程日期",width:150}, {field: 'commodityName', width:250,title:"二程日期"}, {field: 'vehicleType',title: "预计到货日期",width:150}, {field: 'customVehicleType',title: "海船公司",width:150}, {field: 'commodityConfigCopy', width:250,title:"放箱日期"}, {field: 'attachment',filebox:true, width:250,title:"放箱单上传" }, ]]设置放箱单上传为filebox
您可以在DataGrid的columns属性中,在对应列的配置中添加filebox属性来将该列设置为FileBox控件。例如:
```javascript
columns: [
{
field: 'showCheckboxWithId',
checkbox: true,
formatter: function (value, row, index) {
return row.id
}
},
{ field: 'id', title: "id", hidden: true },
{ field: 'productionBarCode', title: "提单号/运单号", width: 150 },
{ field: 'salesBarCode', title: "一程日期", width: 150 },
{ field: 'commodityName', width: 250, title: "二程日期" },
{ field: 'vehicleType', title: "预计到货日期", width: 150 },
{ field: 'customVehicleType', title: "海船公司", width: 150 },
{ field: 'commodityConfigCopy', width: 250, title: "放箱日期" },
{ field: 'attachment', filebox: true, width: 250, title: "放箱单上传" }
]
```
这将在最后一列中显示FileBox控件,并将该列的标题设置为“放箱单上传”。注意,您需要在该列对应的数据中添加一个名为“attachment”的属性,该属性的值将被用作FileBox控件的值。