[英]Extjs GridPanel validation
how can i do a validation function that get me an error when IN1>OU1 or IN2>OU2 ?? 当IN1> OU1或IN2> OU2时,如何做一个使我出错的验证函数?
this is my code (a grid panel with roweditor plugin) 这是我的代码(带有roweditor插件的网格面板)
{
xtype: 'gridpanel',
height: 250,
width: 400,
title: 'My Grid Panel',
columns: [
{
xtype: 'datecolumn',
text: 'IN1',
dataindex 'F02ORAIN1',
field: {
xtype: 'timefield',
id 'editF02ORAIN1'
}
},
{
xtype: 'datecolumn',
dataindex 'F02ORAOU1',
text: 'OU1',
field: {
xtype: 'timefield',
id 'editF02ORAOU1'
}
},
{
xtype: 'datecolumn',
text: 'IN2',
dataindex 'F02ORAIN2',
field: {
xtype: 'timefield',
id 'editF02ORAIN2'
}
},
{
xtype: 'datecolumn',
text: 'OU2',
dataindex 'F02ORAOU2',
field: {
xtype: 'timefield',
id 'editF02ORAOU2'
}
}
],
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
})
]
}
I think the best way is to use field's validator config: 我认为最好的方法是使用字段的验证器配置:
// ...
{
xtype: 'datecolumn',
text: 'IN1',
dataIndex: 'F02ORAIN1',
field: {
xtype: 'timefield',
id: 'editF02ORAIN1',
validator: function(value) {
if (!Ext.getCmp('editF02ORAOU1').getValue()) return true;
if (this.getValue() > Ext.getCmp('editF02ORAOU1').getValue())
return 'IN1 should be less then OU1';
return true;
}
}
}, {
xtype: 'datecolumn',
dataIndex: 'F02ORAOU1',
text: 'OU1',
field: {
xtype: 'timefield',
id: 'editF02ORAOU1'
}
},
// ...
与其使用getCmp(除非进行调试,否则永远不要这样做),而是从商店获取要与数据进行比较的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.