簡體   English   中英

在AlloYUI Diagram Builder中更改節點的默認編輯器

[英]Change default editor for node in AlloYUI Diagram Builder

我必須做一個圖編輯器,所以我使用的是AlloYUI,我在此問題的答案后面添加了一個自定義節點。

我已經成功設置了新節點,並通過diagramBuilder.toJSON()獲取了它的值

我想做的是更改自定義節點的custom屬性的默認編輯器小部件,我想更改日期選擇器小部件的文本框,但是我的目標是能夠使用任何其他表單元素,例如選擇,或一組單選按鈕。

玩弄WebStorm中包含的javascript調試器,我發現默認字段具有“ editor”屬性,其中定義了“ textAreaCellEditor”。

默認節點屬性,如WebStorm調試器中所示

但是我的自定義屬性沒有此屬性,因此我嘗試附加一個編輯器,但無法使其正常工作,我嘗試使用以下方法:

Y.DiagramNodeCustom = Y.Component.create({
        NAME: 'diagram-node',

        ATTRS: {
          type: {
            value: 'custom'
          },
          custom_attr: {
            value: 'customAttr'
          }
        },
        EXTENDS: Y.DiagramNodeTask,

        prototype: {
          getPropertyModel: function () {
            var instance = this;

            var model = Y.DiagramNodeTask.superclass.getPropertyModel.apply(
                instance, arguments);

            model.push({
              attributeName: 'customAttr',
              name: 'Custom Attribute',
              editor: Y.Component.create({
                NAME: "DateField",
                EXTENDS: Y.DateCellEditor
              })
            });

            return model;
          },
          SERIALIZABLE_ATTRS: ['description', 'name', 'required', 'type',
            'width', 'height', 'zIndex', 'xy', 'customAttr']
        }

      });
      Y.DiagramBuilder.types['custom'] = Y.DiagramNodeCustom;

我還嘗試將“ model.push”部分更改為:

model.push({
      attributeName: 'customAttr',
      name: 'Custom Attribute',
      editor: {name: "textCellEditor"}
    });

並:

model.push({
          attributeName: 'customAttr',
          name: 'Custom Attribute',
          editor: Y.DateCellEditor({
            name: 'DateCellEditor'
          })
        });

但是什么都行不通。 您知道如何更改默認編輯器嗎?

感謝羅伯特·弗蘭普頓(Robert Frampton),他在Google網上論壇中解答了我的問題,解決方法是:

model.push({
   attributeName: 'customAttr',
   name: 'Custom Attribute',

   editor: new Y.DateCellEditor()
});

您必須在構造函數之前添加“ new”來創建Y.DateCellEditor對象的新實例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM