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

[Solved] Clientside binding and complex objects

1 Answer 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 12 Mar 2010, 01:30 PM
Hello,

i have a radgrid bound to a list of complex objects. the binding on client side will not show the value of the complex property.
C# class:
public class BladderInstillation : BaseIdentifier  
{  
    public DateTime Date { getset; }  
    public decimal Dosage { getset; }  
    public Agent Agent { getset; }  
}  
 
public class Agent : BaseIdentifier  
{  
    public string Name { getset; }  
    public string AtcCode { getset; }  

Grid column:
<telerik:GridBoundColumn HeaderText="Agent" UniqueName="Agent" DataField="Agent.Name" /> 

Javascript:
$.ajax({  
    type: "POST",  
    url: "MyPage.aspx/Save",  
    data: "{'instillation' : " + Sys.Serialization.JavaScriptSerializer.serialize(instillation) + "}",  
    contentType: "application/json; charset=utf-8",  
    dataType: "json",  
    success: function(data) {  
        for (var i = 0; i < data.d.length; i++) {  
            data.d[i].Date = jsonParseDate(data.d[i].Date).format("dd.MM.yyyy");  
        }  
        var tableView = $find("<%= radGrid.ClientID %>").get_masterTableView();  
        tableView.set_dataSource(data.d);  
        tableView.dataBind();  
        var grid = $find("<%= radGrid.ClientID %>");  
        grid.repaint();  
    }  
}); 

The date and dosage properties will be shown but not the Agent.Name property. How can i achieve this?

Regards,
Dominic

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 15 Mar 2010, 10:21 AM
Hello Dominic,

I am afraid that currently RadGrid will not manage to bind to nested properties by using client-side binding. You can manually bind the column by handling RowDataBound client event and populate the cell for the current row. In the arguments of the handler there are references to the current GridDataItem and DataItem the row is bound to.

All the best,
Nikolay
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
Dominic
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or