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

some explanation on unbound hierarchical mode please

1 Answer 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erdem
Top achievements
Rank 1
Erdem asked on 08 Jul 2015, 06:46 PM

 

Hi,

 I've gone through this page and have a few questions:

 http://www.telerik.com/help/winforms/gridview-populating-with-data-unbound-mode.html

---------
Reason for using Unbound Mode: I'm building a Multi-threaded application, this application has several slow processes in the background and each of them returns a value. I use these values to fill cells in a gridview one by one without blocking the rest of the user interface. I've got this working quite well and happy with the result. I couldn't have done this with binding (this would have resulted in constantly fully reloading the gridview, now I just modify each cell when needed). This is the reason, why I'm using unbound mode.

---------

Now, for my next modification - I need a hierarchy in the gridview and I'm having trouble getting this to work:

I need something like the following:

 

ROW1: AverageValue1 | AverageValue2 | AverageValue3
    ROW1a: Value1a | Value2a | Value3a
    ROW1b: Value1b | Value2b | Value3b
    ROW1c: Value1c | Value2c | Value3c
ROW2: AverageValue1 | AverageValue2 | AverageValue3
    ROW2a: Value1a | Value2a | Value3a
    ROW2b: Value1b | Value2b | Value3b
ROW3: AverageValue1 | AverageValue2 | AverageValue3
    ROW3a: Value1a | Value2a | Value3a
    ROW3b: Value1b | Value2b | Value3b
    ROW3c: Value1c | Value2c | Value3c
    ROW3d: Value1d | Value2d |  Value3d

 

Now, when following the steps for "hierarchical grid in unbound mode" I'm getting way too many child rows. I believe the reason for this is because I'm using a template like so:

GridViewTemplate template = radGridView1.MasterTemplate.Templates[0];

Then I loop through the amount of childrows that need to be created like so:

 

for (int j = 0; j < rowCount; j++)
{
    template.Rows.AddNew();
}

This results in having way too many childrows. I've just taken two random columnnames as the relationship => I'm assuming this is probably the reason why things aren't working.
The thing is, in my case there is no real relationship between child and parent. The parent is just the average values of all children. Does this mean I need to create an extra column just for the sake of the relationship ?

Also, when using unbound mode (in a non-hierarchical situation) I first create the rows, and then fill them. If in hierarchical mode, I'm getting the impression that I can't create the childrows without filling them (not sure)?

All I really want to do, is create child rows an fill the cells one by one, whenever I can....

Thanks in advance for the help and example !

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Jul 2015, 12:54 PM
Hi Erdem,

Thank you for writing.

RadGridView uses templates for its rows. MasterTemplate is the main template, and then for child levels you use child templates. So, the MasterTemplate will hold the top level rows, and its child template will hold the rows for the child template (all of them for all parent rows). When a top row is expanded, based on the parent/child GridViewRelation, the respective subset of the child template rows will be show underneath. Having that said, you need to have valid parent/child relations, so you would need the extra column for the purpose.

As to the many rows, I am not sure what might be causing it, but perhaps you are looking at the child template rows, which holds all rows for the inner template. To get the child rows for a specific hierarchy row, you can check its ChildRows collection, however, when attempting to add a new child row, the latter should be added to the child template with proper value for its relation with the master e.g. if the top row has ID=1 the child row should have its ParentID=1.

If you still experience issues, please get back to us with a small example demonstrating your setup so we can work with the precise case.

Another approach I can suggest is to look at our summary rows functionality. In the following article: http://www.telerik.com/help/winforms/gridview-rows-summary-rows.html, have a look at the "Summary rows in grouped RadGridView" section. The idea is that you could have your data set up on a single level and use the grouping functionality to group by a certain column, and then display summary row for the average of the items in a certain group.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Erdem
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or