I've got a question regarding the Telerik RadGrid control client side binding. I want to populate grid with the cities on the Client Side. I've got a object City, which has a property Country:
I retrieve this data as a JSON object to the client side using the JQuery Ajax and WCF. and then I bind it to the grid:
I appreciate any help solving that issue!
[DataContract][KnownType(typeof(Country))]public class City{ [DataMember] public virtual string CityCode { get; set; } [DataMember] public virtual string CityName { get; set; } [DataMember]} public virtual Country Country { get; set; }} [DataContract]public class Country{ [DataMember] public virtual string CountryCode { get; set; } [DataMember] public virtual string Iso2Code { get; set; } [DataMember] public virtual string CountryName { get; set; } [DataMember] public virtual char RDC { get; set; } }
I retrieve this data as a JSON object to the client side using the JQuery Ajax and WCF. and then I bind it to the grid:
rgCity.set_dataSource(dataItem);rgCity.dataBind();
Here are the Columns definition for the grid: <Columns> <telerik:GridBoundColumn HeaderText="City Code" DataField="CityCode" MaxLength="3"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="City Name" DataField="CityName"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Country Code" DataField="CountryCode" MaxLength="2"></telerik:GridBoundColumn></Columns>
The problem is I'm not getting the Country Code column populated with the data. I think the problem is in data binding, but I'm not sure if is it possible to bind a complex objects. I think should be something like that: <telerik:GridBoundColumn HeaderText="Country Code" DataField="City.CountryCode" MaxLength="2"></telerik:GridBoundColumn>I appreciate any help solving that issue!
