Hierarchical Datagridview

-->
  1. Hierarchical Datagridview Format
  2. Free Hierarchical Datagridview Vb.net
  3. Hierarchical Datagridview C# Winforms

Hierarchical DataGridView is a.NET WinForm grid control that organizes, edits and displays data in hierarchical form. Hierarchical DataGridView is compatible with. Basic Hierarchies. The RadGridView allows you to display hierarchical data in the form of nested grid views. To do so you have to define a table definition for each subset of data you want to display. Such a definition can be done by creating a GridViewTableDefinition object and adding it to the ChildTableDefinitions collection of the RadGridView.

Note Also see the Master/detail sample.

You can make a multi-level master/details (also known as list-details) view of hierarchical data by binding items controls to CollectionViewSource instances that are bound together in a chain. In this topic we use the {x:Bind} markup extension where possible, and the more flexible (but less performant) {Binding} markup extension where necessary.

One common structure for Universal Windows Platform (UWP) apps is to navigate to different details pages when a user makes a selection in a master list. This is useful when you want to provide a rich visual representation of each item at every level in a hierarchy. Another option is to display multiple levels of data on a single page. This is useful when you want to display a few simple lists that let the user quickly drill down to an item of interest. This topic describes how to implement this interaction. The CollectionViewSource instances keep track of the current selection at each hierarchical level.

We'll create a view of a sports team hierarchy that is organized into lists for leagues, divisions, and teams, and includes a team details view. When you select an item from any list, the subsequent views update automatically.

Prerequisites

This topic assumes that you know how to create a basic UWP app. For instructions on creating your first UWP app, see Create your first UWP app using C# or Visual Basic.

Create the project

Create a new Blank Application (Windows Universal) project. Name it 'MasterDetailsBinding'.

Create the data model

Add a new class to your project, name it ViewModel.cs, and add this code to it. This will be your binding source class.

Create the view

Next, expose the binding source class from the class that represents your page of markup. We do that by adding a property of type LeagueList to MainPage.

Hierarchical Datagridview Format

Finally, replace the contents of the MainPage.xaml file with the following markup, which declares three CollectionViewSource instances and binds them together in a chain. The subsequent controls can then bind to the appropriate CollectionViewSource, depending on its level in the hierarchy.

Note that by binding directly to the CollectionViewSource, you're implying that you want to bind to the current item in bindings where the path cannot be found on the collection itself. There's no need to specify the CurrentItem property as the path for the binding, although you can do that if there's any ambiguity. For example, the ContentControl representing the team view has its Content property bound to the TeamsCollectionViewSource. However, the controls in the DataTemplate bind to properties of the Team class because the CollectionViewSource automatically supplies the currently selected team from the teams list when necessary.


This post concentrates on how to show GridView on Hierarchical style with AJAX implementation. I have already blogged one post related to the same concept without AJAX implementation. This post takes the same scenario and implementing the same concept using XML HTTP AJAX implementation.
The use case of the implementation follows:
  1. The page should show a Grid View with list of Orders with Expand icon on the first column.
  2. On click of expand icon on each row, the Order Details of the Order must be fetched from the database and show in the Grid View just below to the row with little adjacent to the first column.
  3. The child Grid View must fetch from the server only on demand to avoid the loading time using AJAX concept.
  4. Once the expand icon clicked, there should be a loading message to inform to the user the details are fetching from the server.
  5. Once the Grid View fetched from the server, the Child Grid should show by hiding the loading message and the expand icon must be changed to collapse icon.
  6. On click of collapse icon, the child grid should hide from the screen.
  7. When the user clicks the Expand which was already trigged before (and Child Grid details fetched from the server) there should not be a call to the server again fetching the same details. The system should show the hidden Grid View.
  8. When the user clicks expand icon before previous expand process completed, the previous process (or loading) must be suspended and the new process should start immediately. (To test this requirement, I coded a sleep statement in the program.)

To know how XML HTTP AJAX works and how to implement the same in ASP.NET page, you can have a look on the post How to implement XML HTTP AJAX in ASP.NET Web Pages.
I am using Northwind database in this example. So to test the code, please make sure you have Northwind database and update the server in connection string on web.config.
I have two aspx page to implement this sample.
  1. Default.aspx – is the page end user accessing. This page contains the main grid which has the Order details. This page had XML HTTP AJAX implementation which calls another page ChildGridBuilder.aspx to get the child Grid View response.
  2. ChildGridBuilder.aspx – is the page act as remote page. This page generates the Child Grid View response which contains the list of Order Details information. As the Grid View is depends on an Order Id, it accepts a Query String for OrderId information. So the Default.aspx page will call this page with the Order Id which is from the expanding row.

The implementation follows:
Default.aspx GridView Script
Default.aspx C# Code behind
Default.aspx Javascript Code
ChildGridBuilder.aspx GridView
ChildGridBuilder.aspx Code behind
CSS StyleSheet
download the working example of the source code in C# here and in VB here
[Update 01 Nov 2011]
The above implementation shows, when clicking the expand icon in the row - it calls the server to get the GridView script and show in the page. Once the GridView shown, it never call again till the page refresh happening and it will just hide and show the GridView.
But some of our requirement is little different-
  1. Whenever the expand button calls, it should call the server to get the GridView script and show in the page. So, it shows the latest GridView data by going to the server every time when clicking the expand button.
    download the example in C# here and in VB here.
  2. It will function like the same way in blog implementation, but additionally with Refresh button. So when expand button clicked, it will call the server to get the GridView script. It will show and hide as per expand button and wont call server once it shown in the page. The GridView also contains a Refresh button and when clicking the button it will call the server to refresh the data. So the data will be fetched from the server on the first time it expand and when the user clicks Refresh button.
    download the example in C# here and in VB here.

[Update]Datagridview
I have blogged another post on the same topic using AJAX and JQuery concepts. Below are the linksHierarchical Datagridview
Hierarchical GridView in ASP.NET
Hierarchical GridView in ASP.NET with AJAX, JQuery implementation - Part 1
Hierarchical GridView in ASP.NET with AJAX, JQuery implementation - Part 2
Below is the output of the screen,
Initial Page

Loading message when loading the Child Grid when expand button clicked

Hierarchical Grid View with some child grid expanded

Free Hierarchical Datagridview Vb.net


Hierarchical Datagridview C# Winforms

Below is the Video outputFree hierarchical datagridview vb.net