这是我的第一篇文章,所以我可能会在错误的线程中发帖,对此表示抱歉。
我想限制数字网格过滤器中的负值,只允许网格中数字过滤器中的正数,我无法找到如何执行此操作。
这是我的代码
var myFilters =
{
ftype : 'filters',
encode : false,
local : false,
extend : 'Ext.data.Model',
filters :
[
{
type : 'numeric',
dataIndex : 'utilization_per'
}
]
};
deviceUtilGridPanel = new Ext.grid.GridPanel(
{
features : [myFilters],
columns :
[
{id:'ru_utilization_per', header: "Utilization(%) (U)", sortable: true, dataIndex: 'utilization_per', filterable: true, filter :{type:'numeric'},width:80}
]
});
任何帮助将不胜感激。
提前致谢。
最佳答案
您可以使用过滤器上的menuItemCfgs
配置来修改过滤器菜单使用的表单字段。
var myFilters = {
ftype: "filters",
encode: false,
local: false,
filters: [{
dataIndex: "utilization_per",
type: "numeric",
menuItemCfgs: {
minValue: 1 // Or 0, or whatever you want
}
}]
};
作为旁注(与答案并不真正相关),您的代码有一些问题。您不需要将 extend
添加到您的过滤器配置中,因为您没有扩展它,并且它不需要了解您的模型。列定义中的 header
配置已被弃用,取而代之的是具有相同功能的 text
。默认情况下,列是可过滤的,因此您不需要 filterable: true
。如果您在过滤器功能配置中指定列过滤器,则无需在列级别指定它。
关于extjs - 如何在extjs网格中的数字过滤器中只允许正数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12494203/