2013-10-17 70 views
1
Below is the kendo code for drop down control. 

我试图显示“请选择”选项。此确切代码适用于除此之外的所有下拉菜单。 选项显示为下拉列表的一部分,但不会在下拉列表加载时显示。请帮助,因为我也尝试关闭并打开Visual Studio并在浏览器中删除历史记录。Kendo optionLabel for drop down not working correctly

 function getRC(rcid) { 
    for (var i = 0; i < ddRCpicklist.length; i++) { 
     if (ddRCpicklist[i].rcID === rcid) { 
      return ddRCpicklist[i].RootCause; 
     } 
    } 
    return 'No value matched'; 
} 

function RootCauseDropDownEditor(container, options) { 
    if (options.model.Name !== null) { 
     var ddRC= $('<input id="ddRootCause" required data-text-field="RootCause" data-value-field="rcID" data-change="ddRootCauseSelect" data-bind="value:' + options.field + '"/>') 
         .appendTo(container) 
         .kendoDropDownList({ 
          index:0, 
          autoBind: false, 
          dataSource: { data: ddRCpicklist }, 
          optionLabel: "--Please Select--" 
         }).data("kendoDropDownList"); 
        } 
    } 

function ddRootCauseSelect(e) { 
    ddValRootCause = $("#ddRootCause").val(); 
    alert(ddValRootCause); 
} 
+0

@Mila它怎么看,解决你的问题有什么好运? – Vojtiik

回答

0

我相信这种独特的行为是指所谓的自定义编辑器。你有没有机会在网格上下拉?基本上,您所看到的代码是将下拉控件注入网格中的容器中(例如,(.appendTo(container))),它会将您的optionValue添加到下拉列表中,但它也会选择网格中显示的值。假设您的下拉选项是A,B,C和-select-,如果网格在列中显示B,则下拉列表将显示B.如果您没有在网格上,则所选值将通过选项传递。

删除以下属性,看看会发生什么:

data-bind="value:' + options.field + '" 
1

optionLabel JSON数据必须是相同的格式为您的数据加载到您的下拉休息。所以对你来说应该是:

optionLabel: { RootCause: '-- Please Select --', rcID: '' }