[You can see all new hierarchy modes of RadGridView in this week’s webinar. See details and register >>]
More and more developers are using ORM frameworks like Telerik OpenAccess, Entity Framework, and NHibernate to save valuable time from writing dependent and synchronization code for the database server. In many
In many of these scenarios the developers are looking for a convenient and quick way to visualize the data and execute sorting, filtering and/or grouping. Now they can with the newly extended hierarchical model of RadGridView, which comes with
Let’s have the following entity model using the well-known Northwind database:
The new version of RadGridView can very easy generate and present this data by using a binding and the AutoGenerateHierarchy property of control:
NorthwindEntities entities =
new
NorthwindEntities();
var query = from suppliers
in
entities.Suppliers select suppliers;
this
.radGridView1.DataSource = query.ToList();
this
.radGridView1.AutoGenerateHierarchy =
true
;
Here is the result of above lines of code:
Let’s look at another entity model from the Northwind database:
If we want to have better control over the presentation, for
private
void
Form2_Load(
object
sender, EventArgs e)
{
NorthwindEntities entities =
new
NorthwindEntities();
var query = from customers
in
entities.Customers select customers;
GridViewTemplate childTemplate = CreateChildTemplate();
GridViewRelation relation =
new
GridViewRelation(
this
.radGridView1.MasterTemplate, childTemplate);
relation.ChildColumnNames.Add(
"Orders"
);
this
.radGridView1.Relations.Add(relation);
this
.radGridView1.DataSource = query.ToList();
}
private
GridViewTemplate CreateChildTemplate()
{
GridViewTemplate childTemplate =
new
GridViewTemplate();
this
.radGridView1.Templates.Add(childTemplate);
GridViewTextBoxColumn column =
new
GridViewTextBoxColumn(
"OrderDate"
);
childTemplate.Columns.Add(column);
column =
new
GridViewTextBoxColumn(
"Freight"
);
childTemplate.Columns.Add(column);
column =
new
GridViewTextBoxColumn(
"ShipName"
);
childTemplate.Columns.Add(column);
column =
new
GridViewTextBoxColumn(
"ShipCountry"
);
childTemplate.Columns.Add(column);
column =
new
GridViewTextBoxColumn(
"ShipCity"
);
childTemplate.Columns.Add(column);
column =
new
GridViewTextBoxColumn(
"ShipAddress"
);
childTemplate.Columns.Add(column);
childTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
return
childTemplate;
}
And the result is nicely formatted hierarchy template which shows only the columns that we have defined:
What is best, Telerik GridView for WinForms takes care of all data operations such as grouping, sorting, and filtering automatically, and without requiring additional settings or coding. The grid also automatically starts the new-in-Q3 2010 mechanism for lazy data loading and processing, which gives better performance and decreases the memory footprint.
Download RadControls for WinForms Q3 2010 today to try these features yourself.
Also join the live webcast on What’s New in RadControls for WinForms and Telerik Reporting for a chance to win a Telerik Premium Collection (worth $1299):
Wednesday, November 17, 11 am Eastern Time: Register here >>
You can also register for some of the other webinars dedicated to the release and learn about all the major new features that ship with the Q3 2010 release. Book your seat for a chance to win a Telerik Premium Collection (worth $1299), a WebUI Test Studio Bundle ($2999) and a TeamPulse License for 10 users ($2490). Check schedule>>
Nikolay Diyanov Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.
Find him on Twitter @n_diyanov or on LinkedIn.