How to open first item of multifield on load of dialog?

血红的双手。 提交于 2019-12-04 17:21:15
rakhi4110

You can listen to the loadcontent event fired by the Multifield after the content has been loaded. If there was no content available initially, use the addItem() method to add an item and then redo the layout.

A sample configuration using multiple path field is shown below. You can adapt the same as per your requirements.

<promo
    jcr:primaryType="cq:Widget"
    fieldLabel="Select Paths"
    name="./paths"
    xtype="multifield">
    <fieldConfig
        jcr:primaryType="nt:unstructured"
        xtype="pathfield" />
    <listeners
        jcr:primaryType="nt:unstructured"
        loadcontent="function(field, record)
        {
           if(record.get('paths') == undefined)
          {
            field.addItem(); field.doLayout();
          }
        }" />
</promo>
Teja Chava

Improving the above provided solution, try to replace the loadcontent line with,

loadcontent="function(field, record) {if(field.getValue().length == 0) {field.addItem();} }"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!