ExtJS 4(Sencha)中的网格默认情况下不允许选择内容.但我想让这成为可能.
我试过这个网格配置:
viewConfig: {
disableSelection: true,
stripeRows: false,
getRowClass: function(record, rowIndex, rowParams, store){
return "x-selectable";
}
},
Run Code Online (Sandbox Code Playgroud)
使用这些css类(基本上针对我在Chrome中可以看到的每个元素):
/* allow grid text selection in Firefox and WebKit based browsers */
.x-selectable,
.x-selectable * {
-moz-user-select: text !important;
-khtml-user-select: text !important;
-webkit-user-select: text !important;
}
.x-grid-row td,
.x-grid-summary-row td,
.x-grid-cell-text,
.x-grid-hd-text,
.x-grid-hd,
.x-grid-row,
.x-grid-row,
.x-grid-cell,
.x-unselectable
{
-moz-user-select: text !important;
-khtml-user-select: text !important;
-webkit-user-select: text !important;
}
Run Code Online (Sandbox Code Playgroud)
我知道你可以覆盖Ext 3中的网格行模板,如下所示,但我不知道如何在Ext 4中做同样的事情:
templates: {
cell: new Ext.Template(
'<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable …Run Code Online (Sandbox Code Playgroud) 假设我有一些Person实体,我想知道一个是否在列表中:
person in people?
Run Code Online (Sandbox Code Playgroud)
我不关心'对象的ID'是什么,只是他们的属性是相同的.所以我把它放在我的基类中:
# value comparison only
def __eq__(self, other):
return (isinstance(other, self.__class__) and self.__dict__ == other.__dict__)
def __ne__(self, other):
return not self.__eq__(other)
Run Code Online (Sandbox Code Playgroud)
但是为了能够在集合中测试相等性,我还需要定义哈希所以......
# sets use __hash__ for equality comparison
def __hash__(self):
return (
self.PersonID,
self.FirstName,
self.LastName,
self.etc_etc...
).__hash__()
Run Code Online (Sandbox Code Playgroud)
问题是我不想列出每个属性,并且我不希望每次属性更改时都修改哈希函数.
这样做可以吗?
# sets use __hash__ for equality comparison
def __hash__(self):
values = tuple(self.__dict__.values())
return hash(values)
Run Code Online (Sandbox Code Playgroud)
这是理智的,而不是TOOOO太大的性能损失?在网络应用程序的情况下.
非常感谢.