【问题标题】:How to reload items collection from webservice using javascript如何使用 javascript 从 web 服务重新加载项目集合
【发布时间】:2015-03-29 23:33:30
【问题描述】:

RadDropDownList 控件绑定到 web 服务。在加载控件填充确定。但我需要在模式窗口关闭后更新项目列表。
用于更新项目列表的 Javascript 函数:

function Templates_RequestData(){
     var dropdown = $find("<%= Me.RadDropDownTemplates.ClientID%>");
     javascript: console.log(dropdown.get_items());  //works ok
     //dropdown.requestItems("", false); - undefined is not a function
     //dropdown.reload(); - undefined is not a function
     //dropdown.clearItems(); - undefined is not a function
     javascript: console.log("reload");
  }

RadDropDownList 控件

<telerik:RadDropDownList ID="RadDropDownTemplates" runat="server"
    Skin="MetroTouch" Width="100%" DropDownWidth="200px" 
    AutoPostBack="false" 
    DefaultMessage=" - select template - "
    OnClientItemsRequesting="Templates_OnItemRequesting"
    SelectedValue='<%# Me.LastUsedTemplateID%>' >
    <WebServiceSettings Path="WebServices/Templates.asmx"
                        Method="GetAll"/>
</telerik:RadDropDownList>

我尝试的所有方法都会导致错误:

"Uncaught TypeError: undefined is not a function"

javascript: console.log(dropdown) - 返回 RadDropDownList 类型的有效对象。 Telerik 的文档不包含任何使用 Web 服务更新项目的功能。
如何从客户端代码更新raddropdownlist

【问题讨论】:

  • requestItems() 方法通常在您有按需加载时使用,RadComboBox 就是这种情况。 RadDropDownList 没有按需加载,因此您可能需要使用另一种方法。最好询问 Telerik 支持。

标签: javascript asp.net telerik


【解决方案1】:

好的,因为我只需要在页面加载时和模式窗口关闭后更新RadDropDownList 的列表。我决定手动制作。

我创建了一个调用 webservice 的 javascript 函数,并从 webservice 的结果创建 DropDownListItems 并将它们添加到我的列表中。
然后在我的RadDropDownListOnClientLoad eventhandler 和RadWindowOnClientClose eventhandler 中调用这个函数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 2020-06-14
    • 1970-01-01
    相关资源
    最近更新 更多