Hello,
I have the following data model which I want to display in TelerikGrid.
The columns should be Name, Price (which is easy), but I also want to display the topping columns, where each caption is the key of the dicionary entry and the displayed value should be the value from the dictionary entry:
Expected result:
Name | Price | Tomato | Cheese | Bacon
Cheese | 8.99 | low | very much | no
Tomato | 5.99 | very much | not so much | no
Bacon | 10.99 | low | not so much | three pieces
Is that possible by using the TelerikGrid and how should the data binding look like ?
I took the sample code from the expando sample to create the columns based on the dictionary entries
but I didn't get the values from the dictionary to display each value in the rows.
public class Pizza
{
public string Name { get; set; }
public decimal Price { get; set; }
public IDictionary<string, string> Toppings { get; set; }
public static IList<Pizza> PizzaRecipies()
{
return new List<Pizza>()
{
new Pizza()
{
Name = "Cheese",
Price = 8.99M,
Toppings = new Dictionary<string, string>()
{
{"Tomato","low"},
{"Cheese", "very much"},
{"Bacon", "no"}
}
},
new Pizza()
{
Name = "Tomato",
Price = 5.99M,
Toppings = new Dictionary<string, string>()
{
{"Tomato","very much"},
{"Cheese", "not so much"},
{"Bacon", "no"}
}
},
new Pizza()
{
Name = "Bacon",
Price = 10.99M,
Toppings = new Dictionary<string, string>()
{
{"Tomato","low"},
{"Cheese", "not so much"},
{"Bacon", "three pieces"}
}
}
};
}
}