【问题标题】:How to set the Alfresco drop down list to show a default value?如何设置 Alfresco 下拉列表以显示默认值?
【发布时间】:2017-01-10 22:54:33
【问题描述】:

我正在使用 Alfresco selectone.ftl 来自定义下拉列表。我不想将任何空白选项显示为默认值。但是 Selectone.ftl 会自动添加一个空白选项。如何将my value设置为默认并删除空白选项。

【问题讨论】:

    标签: alfresco freemarker alfresco-share


    【解决方案1】:

    有一个要求,我必须根据某些条件在下拉列表中显示用户列表,因为我已经按照下面的代码自定义了 selectone.ftl,可能对你有帮助。

    ** 这是custom-selectone.ftl**

    <div class="form-field">
    <script type="text/javascript">//<![CDATA[
    YAHOO.util.Event.onAvailable("${fieldHtmlId}", function(){
        new selectAjax("${fieldHtmlId}");
    });
    function selectAjax(currentValueHtmlId) {
        this.currentValueHtmlId = currentValueHtmlId;
        var select = Dom.get(this.currentValueHtmlId);
        this.register = function () {
            Alfresco.util.Ajax.jsonGet({
                url: Alfresco.constants.PROXY_URI+"userwebsacript",
                successCallback: {
                    fn: this.updateOptions,
                    scope: this
                },
                failureCallback: {
                    fn: function(){},
                    scope: this
                }
            });
        };
        this.updateOptions = function (res) {
    
            var result = res.serverResponse.responseText;
            if (result.length > 0) {
                var sp=result.split(",");
                for(var i=0;i<sp.length;i++){
                    var option = new Option(sp[i], sp[i]);
                    select.options[select.options.length] = option;
                }  
            }
        };
    
        this.register();
    }
    //]]></script>
    <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
    <select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
            <#if field.description??>title="${field.description}"</#if>
            <#if field.control.params.size??>size="${field.control.params.size}"</#if>
            <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
            <#if field.control.params.style??>style="${field.control.params.style}"</#if>
            <#if field.disabled  && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if>>
            <option value="">Select</option>
    </select>
    

    【讨论】:

      猜你喜欢
      • 2020-07-06
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-16
      • 2014-07-28
      • 2016-09-16
      • 1970-01-01
      • 2014-07-19
      相关资源
      最近更新 更多