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

Dynamicly configure sub totals

5 Answers 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 18 Jan 2011, 07:02 AM
I have a requirement that is the complete reversal of most grid requirements. I am loading a gridview from a stored procedure where I do not know the number or name of the columns. This works great with the auto generate columns and the grouping.

Now I need to add the ability for the user to set subtotals on 1 or more column and to hide other columns. Is there a sample around where this type of dynamic configuration is done in the code behind.

5 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 18 Jan 2011, 06:51 PM
Hello Mark,

I am sending you a sample project illustrating how you may achieve the desired result. Let me know if you need any further assistance.
 

Kind regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Mark
Top achievements
Rank 1
answered on 19 Jan 2011, 01:32 AM
Thanks Maya, thats is how I thought it would work, when I was attempting this the rebind caused an error but that may be because of the data format (numerics are in a string column and I was using sum). This will allow me to isolate and nail the problem without questioning to design.
0
Maya
Telerik team
answered on 19 Jan 2011, 08:49 AM
Hello Mark,

Generally, if you use a GridViewDataColumn, it will work accordingly to the DataType of the property. So, once you define a numeric property, there should be no reason for you not to able to apply a Sum function on it. 
As a whole, did you manage to resolve your issue ?

All the best,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Mark
Top achievements
Rank 1
answered on 19 Jan 2011, 10:04 AM
Spent the entire day chasing down xml/xst parsing problems. I now have the data table building properly with the correct data types and your dynamic totals work perfectly, thank you. Hiding columns will be a no brainer from there.

As they say do a good job and you just get more work - is it possible to add group totals from the code behind (just fiddling around and dropped a group and low and behold group totals as well). Your work here is done thank you very much!
0
Maya
Telerik team
answered on 19 Jan 2011, 10:43 AM
Hi Mark,

RadGridView supports two types of group descriptors - GroupDescriptor and ColumnGroupDescriptor. Since Q3 2010, a ColumnGroupDescriptor is added when grouping by the UI. Generally, it is quite more aware of its corresponding column than the regular GroupDescriptor. You may take a look at our online documentation for a reference.
So, if you have already defined aggregates for a particular column and added a ColumnGroupDescriptor, the function will be directly displayed in the GroupRow. Thus, following the sample project above, you may handle the Click event of the second buttons as follows:

private void RadButton_Click_1(object sender, RoutedEventArgs e)
{
     ColumnGroupDescriptor groupDescriptor = new ColumnGroupDescriptor();
     groupDescriptor.Column = this.clubsGrid.Columns[0];
     this.clubsGrid.GroupDescriptors.Add(groupDescriptor);
}

So, once you have added the CountFunction by clicking on the first button, the groups and the corresponding aggregates will be created. 
  

All the best,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mark
Top achievements
Rank 1
Share this question
or