This is a migrated thread and some comments may be shown as answers.

WCF Livedata

4 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 24 Mar 2010, 02:07 AM

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

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 24 Mar 2010, 10:47 AM
Hello David,

In order to force rebinding when using declarative client-side data-binding you should call tableView's rebind method. As follows:

function updateGrid()  
{  
    var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();  
    tableView.rebind();  
}  


Regards,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 24 Mar 2010, 12:00 PM
Thanks
0
David
Top achievements
Rank 1
answered on 24 Mar 2010, 12:43 PM
Can I use grouping with this client-side dtabinding?. Someting like this
0
Rosen
Telerik team
answered on 24 Mar 2010, 05:11 PM
Hello David,

I'm afraid that grouping when using client-side databinding is currently not supported.

Best wishes,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Rosen
Telerik team
David
Top achievements
Rank 1
Share this question
or