2012-03-22 104 views
0

好吧,問題是,我想要綁定列表視圖在客戶端。我在論壇和演示中找到了解決方案,但是我在set_dataSource(data)上出錯。像set_dataSource是未定義的,但我不能在客戶端設置中找到標籤,因爲它在演示中顯示。我正在使用telerik的2011.2.915.40版本。綁定RadListView客戶端端

下面是我的aspx代碼:

<telerik:RadListView ID="lstViewNotes" runat="server" OnItemCommand="lstViewNotes_ItemCommand"> 
<EmptyDataTemplate> 
<table id="Table1" style=""> 
<tr> 
<td> 
<%=GetGlobalResourceObject("General","EmptyData") %> 
</td> 
</tr> 
</table> 
</EmptyDataTemplate> 
<ItemTemplate> 
       <table> 
<tr> 
<td colspan="3"> 
<div style="width: 100%"> 
<asp:HiddenField ID="hfNoteId" runat="server" Value='<%#Eval("NotesId") %>' /> 
<asp:LinkButton ID="lblCreate" runat="server" Text='<%#Eval("UserName") %>' CssClass="label_n_t" 
CommandName="Select" /><asp:LinkButton ID="NameLabel" runat="server" Text='<%# Eval("CreateDate") %>' 
CssClass="label_n_t" CommandName="Select" /></div> 
<div style="width: 100%"> 
<asp:LinkButton ID="lblNotesDesc" runat="server" Text='<%# Eval("MemoDesc") %>' CssClass="label_n_c" 
CommandName="Select" /><br /> 
<br /> 
</div> 
</td> 
</tr> 
        </table> 
</ItemTemplate> 
</telerik:RadListView> 

下面是我的JS代碼:

var listView = $find('<%= lstMemo.ClientID%>'); 
listView.set_dataSource(result.lstMemo); 
listView.dataBind(); 

我已經更新了Telerik的論壇,這個問題太,但我沒有得到任何迴應。如果您有任何一個人有解決方案,請回復我。

回答

0

在客戶端AJAX框架完全加載之前它將不可用。

要綁定RadListView到JavaScript數組,使用set_dataSource()和數據綁定()在客戶端AJAX框架(和RadListView)與後加載

的API什麼是您的數據源result長得什麼樣子?它是一個數組嗎? ASMX網絡服務? WCF服務?

綁定到JavaScript數組 要綁定RadListView到javascript 陣列,使用set_dataSource()和數據綁定()中的一個點的API 之後的客戶端AJAX框架(和RadListView)加載:

protected override void 
OnPreLoad(EventArgs e) { 
    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); 
    MyData.BusinessDataStorage.GetData().ForEach(item => 
    { 
     ScriptManager.RegisterArrayDeclaration(Page, "pageData", serializer.Serialize(item)); 
    }); 
    base.OnPreLoad(e); } 

綁定到ASMX Web服務 要綁定RadLis tView到ASMX的Web 服務,您需要設置以下屬性: •位置:服務基地位置 •數據路徑:數據方法的名稱•CountPath :計數方法的名稱,如果需要的話 •SortParameterType:排序表達式格式,如果支持 •FilterParameterType:篩選表達式格式(如果支持)

如果在同一個服務 調用中返回數據和總行計數,則省略CountPath設置。在這種情況下,RadListView 分別在Web服務JSON 響應中搜索名稱爲Data和Count的字段。修改響應字段的名稱 RadListView查找,設置DataPropertyName和CountPropertyName 設置。綁定到WCF服務爲了將自動數據綁定到WCF 服務,RadListView的配置方式與ASMX Web 服務相同。在這個例子中,RadListView綁定到一個WCF服務,它 返回數據,並計算在一個請求:

綁定到的OData服務 綁定RadListView到OData服務是 非常簡單。唯一需要的兩個參數是地址 和HttpMethod =「Get」。 OData服務需要 RadListView中的GET請求。此外,如果一個遠程的OData請求被訪問(和 它支持JSONP)的responseType =也被添加 「JSONP」,以確保 RadListView可以使一個遠程服務請求:

http://www.telerik.com/help/aspnet-ajax/listview-clientside-various-datasources.html 的http:// WWW。 telerik.com/help/aspnet-ajax/listview-clientside-binding-specifics.html

+0

我已經通過這個文件,但問題仍然一樣,我怎麼才能分配參數,當我沒有得到DataBinding標籤內的clientsettings .. – 2012-03-23 04:46:15

+0

@Dhaval是'listView'發現並正確填充控件正確? – msigman 2012-03-24 17:30:42