更改 SmartGWT 中的网格列过滤器
如果您在 SmartGWT 中创建自定义 DataSource ,是否可以删除字段过滤器而不是将其完全从网格列中隐藏?
如下所示:
国家/地区代码字段存在,但隐藏在上图中。
说明:我想在开始时隐藏“国家/地区代码”字段,但仍使其在“列”上下文菜单中可见。如果您使用setHidden(true)
,该字段将从上面的列菜单中消失。
示例代码:
public class MyDataSource extends DataSource {
public MyDataSource() {
DataSourceField countryField = new DataSourceIntegerField("country", "Country code");
// TODO Find a method that disables the filter, aka hides but not removes the field from the grid.
countryField.setHidden(true); // Completely hides/removes the field, not desireable.
countryField.setCanFilter(true); // Doesn't seem to change anything.
addField(countryField);
// Other fields...
}
}
如何在具有上述数据源的 ListGrid 中实现这一点?
If you create a custom DataSource in SmartGWT, is it possible to remove a field filter instead of hiding it entirely from the grid columns?
As seen here:
The Country code field exists, but is hidden in the above image.
Clarification: I want to hide the Country code field at the start, but still have it visible in the Columns context menu. If you use setHidden(true)
the field disappears from the Columns menu above.
Example code:
public class MyDataSource extends DataSource {
public MyDataSource() {
DataSourceField countryField = new DataSourceIntegerField("country", "Country code");
// TODO Find a method that disables the filter, aka hides but not removes the field from the grid.
countryField.setHidden(true); // Completely hides/removes the field, not desireable.
countryField.setCanFilter(true); // Doesn't seem to change anything.
addField(countryField);
// Other fields...
}
}
How would this be achieved in a ListGrid with the above DataSource?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否完全理解了这个问题。
您是否正在寻找一种方法来隐藏列上下文菜单中的“国家/地区代码”选项?你可以通过声明来做到这一点
< code>ListGridField.setCanHide(false) 到相应的ListGridField。
或者,您是否尝试禁用过滤?
如果是这样,在某些情况下用户是否必须可以选择查看国家/地区代码列?
如果没有,您可以保留
MyDataSource
不变,并仅定义您希望用户看到的那些ListGridFields
。底层国家/地区代码属性在代码中仍然可用,例如。通过
record.getAttribute("countryCode");
,它只是没有显示在 ListGrid 中。或者,您可以使用
ListGridField.canFilter(Boolean canFilter)
。编辑:
因此,不要在数据源中设置隐藏属性,而是直接设置到
ListGridField
。DataSource
ListGrid
这应该可以解决问题。
I'm not sure if I fully understood the question.
Are you looking for a way to hide the "Country code" option from the Columns context menu? You can do that by declaring
ListGridField.setCanHide(false)
to the corresponding ListGridField.Or, are you trying to disable filtering?
If so, does the user have to have the option to see the country code column in some cases?
If not, you can just leave the
MyDataSource
as it is and define only thoseListGridFields
that you want the user to see.The underlying country code attribute is still available in the code, eg. via
record.getAttribute("countryCode");
, it's just not shown in the ListGrid.Alternatively, you can define the filtering on grid level with
ListGridField.canFilter(Boolean canFilter)
.EDIT:
So, don't set the hidden attribute in the datasource, but instead directly to the
ListGridField
.DataSource
ListGrid
That should do the trick.