【问题标题】:Dojo Datagrid editable cell, constraints not workingDojo Datagrid 可编辑单元格,约束不起作用
【发布时间】:2011-11-02 00:19:54
【问题描述】:

我正在尝试创建一个带有可编辑单元格的数据网格。 当我对可编辑单元格使用 dijits 时,我尝试在布局的“widgetProps”属性中设置约束,如下所示:

   widgetProps: {
       required: true,
       constraints: {
           min: 0,
           max: 100,
           places: '0,2'
       }
   }

这里 required: true 按预期工作,而 constraints 属性根本不起作用。

这里有一个例子:http://jsfiddle.net/LjVmJ/ 我尝试在 NumberTextBox 和 DateTextBox 中都使用约束。

Dojo 中的错误还是我遗漏了什么?

【问题讨论】:

    标签: datagrid dojo


    【解决方案1】:

    来自 Dojo 邮件列表上的 Oliver:
    它应该是“约束”,并且应该放在“widgetProps”之外。

    这解决了问题。

    【讨论】:

      【解决方案2】:

      我找到了解决这个问题的“肮脏”解决方案:

      首先用所需的约束声明我自己的 NumberTextBox:

      dojo.declare(
          "my.custom.PercentageNumberTextBox", 
          [dijit.form.NumberTextBox],
          {
              postCreate: function(){
                  this.inherited(arguments);
                  this.set('constraints', {min:0,max:100, places:'0,2'});
          }
      });
      

      那我就用它作为网格结构中的widgetClass:

          {
              field: 'employmentPercentage',
              name: 'Employment %',
              type: dojox.grid.cells._Widget,
              widgetProps: { required: true },
              widgetClass: my.custom.PercentageNumberTextBox,
              editable: true,
              width: '150px'
          }
      

      这是目前的一种解决方法(此处为完整示例:http://jsfiddle.net/LjVmJ/2/),

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多