客户端绑定 Telerik RadListView 不工作,缺少什么?
Client Side binding Telerik RadListView not working, what is missing?
我似乎可以使用 Telerik 控件让客户端绑定工作(2 天后)。我没有提供正确类型的假 value/pair 数据吗?找不到正确的控件 ID?
需要做什么才能从客户端正确地将数据绑定到 Telerik RadListView?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Admin.WebForm1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title>
<script type="text/javascript">
//
</script>
<script src="scripts/jquery-2.1.1.min.js"></script> </head> <body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="rsm1" runat="server"></telerik:RadScriptManager>
<telerik:RadListView
ItemPlaceholderID="itemPlaceHolder"
ID="listviewHere" runat="server" ClientIDMode="Static">
<ClientSettings>
<DataBinding>
<LayoutTemplate>
<ul id="itemPlaceHolder">
</ul>
</LayoutTemplate>
<AlternatingItemTemplate>
</AlternatingItemTemplate>
<EmptyDataTemplate>
nothing
</EmptyDataTemplate>
<ItemTemplate>
<li>#= id # ----sdfdsfsdsdf</li>
</ItemTemplate>
</DataBinding>
</ClientSettings>
</telerik:RadListView>
</div>
</form>
<script type="text/javascript">
//$("#grid1").hide();
//$("#listviewHere").show();
$(document).ready(function () {
var data = [{ id: 1, name: "name1", value: 12.4 }, { id: 2, name: "name2", value: 12.4 }];
var listView = $find("#listviewHere");
//var listView = listviewHere().get_masterTableView();
//listView.get_masterTableView();
listView.set_dataSource(data);
listView.dataBind();
});
</script>
</body> </html>
您没有正确找到列表视图客户端对象 - 您应该使用:
var listView = $find('<%= listviewHere.ClientID %>');
查看他们网站上的客户端数据绑定演示:
http://demos.telerik.com/aspnet-ajax/listview/examples/client/appendingdata/defaultcs.aspx
我似乎可以使用 Telerik 控件让客户端绑定工作(2 天后)。我没有提供正确类型的假 value/pair 数据吗?找不到正确的控件 ID?
需要做什么才能从客户端正确地将数据绑定到 Telerik RadListView?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Admin.WebForm1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title>
<script type="text/javascript">
//
</script>
<script src="scripts/jquery-2.1.1.min.js"></script> </head> <body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="rsm1" runat="server"></telerik:RadScriptManager>
<telerik:RadListView
ItemPlaceholderID="itemPlaceHolder"
ID="listviewHere" runat="server" ClientIDMode="Static">
<ClientSettings>
<DataBinding>
<LayoutTemplate>
<ul id="itemPlaceHolder">
</ul>
</LayoutTemplate>
<AlternatingItemTemplate>
</AlternatingItemTemplate>
<EmptyDataTemplate>
nothing
</EmptyDataTemplate>
<ItemTemplate>
<li>#= id # ----sdfdsfsdsdf</li>
</ItemTemplate>
</DataBinding>
</ClientSettings>
</telerik:RadListView>
</div>
</form>
<script type="text/javascript">
//$("#grid1").hide();
//$("#listviewHere").show();
$(document).ready(function () {
var data = [{ id: 1, name: "name1", value: 12.4 }, { id: 2, name: "name2", value: 12.4 }];
var listView = $find("#listviewHere");
//var listView = listviewHere().get_masterTableView();
//listView.get_masterTableView();
listView.set_dataSource(data);
listView.dataBind();
});
</script>
</body> </html>
您没有正确找到列表视图客户端对象 - 您应该使用:
var listView = $find('<%= listviewHere.ClientID %>');
查看他们网站上的客户端数据绑定演示:
http://demos.telerik.com/aspnet-ajax/listview/examples/client/appendingdata/defaultcs.aspx