ligerUI grid 表格中,在一个单元格中写了一个popup,希望选中弹出列表的一条数据后,当前单元格和另一个单元格自动赋值
时间: 2024-05-06 15:17:17 浏览: 12
在ligerUI grid表格中,可以监听popup的选择事件,在选择后获取选中的数据并赋值给当前单元格以及另一个单元格。
具体实现步骤如下:
1. 在popup中设置选择事件监听函数,例如:
```javascript
popup: {
onSelect: function (rowdata) {
// 获取选中的数据
var selectedData = rowdata;
// 赋值给当前单元格
$("#grid").ligerGrid().setCell(selectedData, "currentCellId");
// 赋值给另一个单元格
$("#grid").ligerGrid().setCell(selectedData, "anotherCellId");
}
}
```
其中,currentCellId和anotherCellId分别为当前单元格和另一个单元格的id。
2. 在grid表格中获取当前单元格和另一个单元格的id,并在列定义中设置popup属性,例如:
```javascript
{ display: "当前单元格", name: "currentCellId", align: "center", width: 120, editor: { type: "popup", valueField: "id", textField: "name", popupWidth: 500, popup: { url: "popup.html", width: 500, height: 400, onSelect: function(rowdata) { } } } },
{ display: "另一个单元格", name: "anotherCellId", align: "center", width: 120, editor: { type: "text" } }
```
其中,popup属性中的url为弹出列表的页面地址,width和height为弹出列表的宽度和高度。