当IN1>OU1或IN2>OU2出现错误时,我该如何执行验证函数??
这是我的代码(一个带有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', {
})
]
}发布于 2011-09-06 21:01:59
不要使用getCmp (除非进行调试,否则永远不要使用),而是从存储中获取要与值进行比较的数据。
发布于 2011-09-06 19:30:50
我认为最好的方法是使用field的validator配置:
// ...
{
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'
}
},
// ...Here is demo
https://stackoverflow.com/questions/7318802
复制相似问题