ExtjsModern设置selectable在最后一列
时间: 2024-05-14 07:17:13 浏览: 8
要在 ExtJS Modern Grid 的最后一列启用可选择性,你需要按照以下步骤操作:
1. 在 Grid 的列定义中,将最后一列的 `cell` 配置的 `selectable` 属性设置为 `true`,如下所示:
```
{
text: '最后一列',
dataIndex: 'lastColumn',
cell: {
selectable: true
}
}
```
2. 在 Grid 的 `itemConfig` 配置中,针对最后一列的单元格,将 `userSelectable` 属性设置为 `true`,如下所示:
```
itemConfig: {
viewModel: true,
body: {
userSelectable: '{record.lastColumn}',
tpl: '{lastColumn}'
}
}
```
这样,在最后一列中的单元格就可以被选中了。注意,这个属性只在 Modern Grid 中可用。
相关问题
ExtjsModern设置selectable在最后一行
要在ExtJS Modern中设置最后一行可选中,可以使用以下代码:
```
// 获取grid组件
var grid = Ext.getCmp('myGrid');
// 获取最后一行
var lastRow = grid.getItemAt(grid.getStore().getCount() - 1);
// 设置最后一行可选中
lastRow.setSelectable(true);
```
其中,`myGrid`是你的Grid组件的ID,你需要将其替换为你的实际ID。这段代码将获取Grid的最后一行,并将其设置为可选中状态。
QTreeWidgetItem设置某一列不可选中
在使用 QTreeWidgetItem 进行树形控件的开发时,你可以通过设置特定列的 Qt.ItemIsSelectable 属性为 False 来使其不可选中。以下是一个示例代码:
```python
# 导入必要的模块
from PyQt5.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem, QWidget
# 创建应用程序和窗口
app = QApplication([])
window = QWidget()
# 创建树形控件
tree = QTreeWidget(window)
tree.setColumnCount(3)
# 创建根节点
root = QTreeWidgetItem(tree)
root.setText(0, "Root")
# 创建子节点并设置特定列的 ItemIsSelectable 属性为 False
child1 = QTreeWidgetItem(root)
child1.setText(0, "Child 1")
child1.setText(1, "Selectable")
child1.setText(2, "Selectable")
child1.setFlags(child1.flags() & ~Qt.ItemIsSelectable) # 第二列不可选中
child2 = QTreeWidgetItem(root)
child2.setText(0, "Child 2")
child2.setText(1, "Selectable")
child2.setText(2, "Selectable")
child2.setFlags(child2.flags() & ~Qt.ItemIsSelectable) # 第二列不可选中
# 将树形控件添加到窗口并显示
window.setCentralWidget(tree)
window.show()
app.exec()
```
在上述示例中,我们创建了一个树形控件,并且设置了三个列。然后,我们创建了一个根节点和两个子节点,并在第二列和第三列上设置了文本。接着,使用 `setFlags()` 方法,我们将子节点的第二列的 `ItemIsSelectable` 属性设置为 False,从而使其不可选中。
你可以根据需要修改示例代码中的列数、节点数量和属性设置。希望这可以帮助到你!
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)