首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Extjs GridPanel验证

Extjs GridPanel验证
EN

Stack Overflow用户
提问于 2011-09-06 19:00:27
回答 2查看 7.2K关注 0票数 2

当IN1>OU1或IN2>OU2出现错误时,我该如何执行验证函数??

这是我的代码(一个带有roweditor插件的网格面板)

代码语言:javascript
复制
{
 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', {
    })
 ]
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-09-06 21:01:59

不要使用getCmp (除非进行调试,否则永远不要使用),而是从存储中获取要与值进行比较的数据。

票数 0
EN

Stack Overflow用户

发布于 2011-09-06 19:30:50

我认为最好的方法是使用field的validator配置:

代码语言:javascript
复制
// ...
{
    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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7318802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档