How could I use the example livedata with WCF client-side databinding?
Something like
aspx file
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head id="Head1" runat="server"> |
| <title></title> |
| <%--Scripting--%> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| //<![CDATA[ |
| function pageLoad(sender, args) |
| { |
| setInterval("updateGrid()",1000); |
| } |
| function updateGrid() |
| { |
| var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); |
| tableView.dataBind(); |
| } |
| //]]> |
| </script> |
| </telerik:RadCodeBlock> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowPaging="True" |
| AllowSorting="True"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn DataField="ProductID" HeaderText="ProductID" DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" DataType="System.String"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="UnitPrice" DataType="System.Decimal" |
| DataFormatString="{0:C}"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ReorderLevel" HeaderText="ReorderLevel" DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderText="Discontinued" DataType="System.Boolean"> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridBoundColumn DataField="Date" HeaderText="Date" DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <DataBinding SelectMethod="GetDataAndCount" Location="~/Service.svc" |
| SortParameterType="Linq" FilterParameterType="Linq"> |
| </DataBinding> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| </form> |
| </body> |
| </html> |
And the service.svc
| [DataContract] |
| public class Product { |
| [DataMember] |
| public int ProductID { |
| get; |
| set; |
| } |
| [DataMember] |
| public string ProductName { |
| get; |
| set; |
| } |
| [DataMember] |
| public decimal? UnitPrice { |
| get; |
| set; |
| } |
| [DataMember] |
| public short? ReorderLevel { |
| get; |
| set; |
| } |
| [DataMember] |
| public bool Discontinued { |
| get; |
| set; |
| } |
| [DataMember] |
| public int Date { |
| get; |
| set; |
| } |
| } |
| public class ResultData { |
| public int Count { |
| get; |
| set; |
| } |
| public List<Product> Data { |
| get; |
| set; |
| } |
| } |
| [ServiceKnownType( typeof( Product ) )] |
| [ServiceContract( Namespace = "" )] |
| [AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed )] |
| public class PosicionService { |
| [OperationContract] |
| public ResultData GetDataAndCount( int startRowIndex, int maximumRows, string sortExpression, string filterExpression ) { |
| ResultData result = new ResultData(); |
| List<Product> lista = new List<Product>(); |
| for ( int i = 0; i < 50; i++ ) { |
| Product producto = new Product(); |
| producto.ProductID = 1; |
| producto.ProductName = "Name"; |
| producto.UnitPrice = 200; |
| producto.ReorderLevel = 1; |
| producto.Discontinued = false; |
| producto.Date = DateTime.Now.Minute; |
| lista.Add( producto ); |
| } |
| result.Data = lista; |
| result.Count = 50; |
| return result; |
| } |
| } |
I want to use declarative client-side data-binding of RadGrid for ASP.NET AJAX to WCF Web Service but a need to refresh data each 20 seconds and i need to use pagging and sorting functionality.
Thanks