We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridGroupingControl and QueryCustomSummary

Thread ID:

Created:

Updated:

Platform:

Replies:

51328 Nov 2,2006 04:37 PM Nov 8,2006 01:28 PM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 2, 2006 04:37 PM

Good evening. I am attempting to implement a custom summary row on a GridGroupingControl. I have used the CustomSummary sample that I found in the Syncfusion sample projects to direct me in the proper setup of the summary columns, rows, and custom Summary classes which are responsible for calculating the summaries.

I am having a problem with the QueryCustomSummary event handler though. After I have created the single row with a couple of custom summary columns, I attach the handler to the grid. Upon loading, the QueryCustomSummary handler is not invoked, so my custom class is not accessed for generating summary information.

I am able to successfully run the CustomSummary sample, and have found that the handler can either be attached like:

this.gridGroupingControl1.QueryCustomSummary += new GridQueryCustomSummaryEventHandler(gridGroupingControl1_QueryCustomSummary);

or
this.gridGroupingControl1.TableDescriptor.QueryCustomSummary += new GridQueryCustomSummaryEventHandler(gridGroupingControl1_QueryCustomSummary);

and will then be invoked before the form becomes visible. However, I cannot seem to invoke the QueryCustomSummary event handler in my code, both through my regular application as well as a sample app I created to assist with these sorts of things.

Are there grid settings or properties that I need to be aware of in order for the handler to be invoked and to process my custom summaries? I am at a loss as to why neither of my projects are behaving as expected.

Thanks for any assistance you can provide.

Administrator [Syncfusion]
Replied On November 2, 2006 11:24 PM

Hi John,

If you are allowing the user to change eithe rthe key column or the column being summarized, you should handle the TableControlCurrentCellAcceptedChanges event to update the summary row in a grid. Below is a code snippet

//needed if you are allowing the user to change eithe rthe key column or the column being summarized.
private void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);
if(style.TableCellIdentity.Column != null &&
( style.TableCellIdentity.Column.Name == WeightedSummary.KeyColumnName
|| style.TableCellIdentity.Column.Name == "Col2"))
{
style.TableCellIdentity.DisplayElement.GetRecord().EndEdit();
this.gridGroupingControl1.Refresh();
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGCSummary3_3bd340.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 3, 2006 02:08 PM

Hi Haneef,

Thanks for your response. That is not exactly what I was looking for, but I did determine the cause for my problems.

I found that the QueryCustomSummary handler must be attached BEFORE the summary rows are added to the grid; otherwise, the summary methods are not created and the summaries will never be calculated. I changed the order of building my summary on the grid, and now my custom summary object is being invoked properly.

I do have a related question though. As it is right now, the summaries are updated when I add a new row to my grid (and thus a new entity to the underlying data source), but I cannot seem to find a way to trigger an update on the summary when the underlying values are changed. The problem may be a result of the fact that the summary is being generated off of unbound columns, and thus changes in the data may not trigger the update appropriately.

Are there any methods which will force the summaries to recalculate, based on whatever the current available information is?

Thanks for your continued assistance.

>Hi John,

If you are allowing the user to change eithe rthe key column or the column being summarized, you should handle the TableControlCurrentCellAcceptedChanges event to update the summary row in a grid. Below is a code snippet

//needed if you are allowing the user to change eithe rthe key column or the column being summarized.
private void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);
if(style.TableCellIdentity.Column != null &&
( style.TableCellIdentity.Column.Name == WeightedSummary.KeyColumnName
|| style.TableCellIdentity.Column.Name == "Col2"))
{
style.TableCellIdentity.DisplayElement.GetRecord().EndEdit();
this.gridGroupingControl1.Refresh();
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGCSummary3_3bd340.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 6, 2006 12:02 AM

Hi John,

By default, the summaries should be refreshed as you leave the row (not the cell). If you want the summaries updated as you leave the cell , you can add a CurrentRecordContextChange event handler, and trigger the actions there.

private void grid1_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if(e.Action == CurrentRecordAction.CurrentFieldChanged)
{
this.gridGroupingControl1.CurrencyManager.EndCurrentEdit();
this.gridGroupingControl1.Table.InvalidateSummary();
}
}

To update the summaries as you change the underlying datasource, Please refer to the below form thread.
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=20247

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 8, 2006 01:28 PM

Hi Haneef,

Thanks for your help! That gave me what I needed for the summary refresh!

>Hi John,

By default, the summaries should be refreshed as you leave the row (not the cell). If you want the summaries updated as you leave the cell , you can add a CurrentRecordContextChange event handler, and trigger the actions there.

private void grid1_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if(e.Action == CurrentRecordAction.CurrentFieldChanged)
{
this.gridGroupingControl1.CurrencyManager.EndCurrentEdit();
this.gridGroupingControl1.Table.InvalidateSummary();
}
}

To update the summaries as you change the underlying datasource, Please refer to the below form thread.
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=20247

Best Regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;