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. Image for the cookie policy date
close icon

Making Cells in Summary Row Editable

Is there any way to make cells in a summary row editable? I tried the following but it does not work: this.gridDBGrouping.Table.TableDescriptor.SummaryRows["Totals"].SummaryColumns["QuoteValueMax"].Appearance.GroupCaptionSummaryCell.CellType = "TextBox"; this.gridDBGrouping.Table.TableDescriptor.SummaryRows["Totals"].SummaryColumns["QuoteValueMax"].Appearance.GroupCaptionSummaryCell.Enabled = true; this.gridDBGrouping.Table.TableDescriptor.SummaryRows["Totals"].SummaryColumns["QuoteValueMax"].Appearance.GroupCaptionSummaryCell.ReadOnly = false; this.gridDBGrouping.Table.TableDescriptor.SummaryRows["Totals"].SummaryColumns["QuoteValueMax"].Appearance.GroupCaptionSummaryCell.AllowEnter = true; Thanks, Erlly

15 Replies

AD Administrator Syncfusion Team September 8, 2004 09:49 AM UTC

Hi Erlly, the problem here is that the grid is explitly setting these cells ReadOnly before QueryCellStyleInfo is raised. What you can do is handle QueryCellStyleInfo and set e.Style.ReadOnly = false. This will override the readonly setting for the cell style object. Example: this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { // Get Field if (column != null && (style.TableCellIdentity.DisplayElement is GridSummaryRow) // -or - e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell)) // -or - e.TableCellIdentity.SummaryColumn != null { e.Style.ReadOnly = false; } } Stefan


EB Erlly Bayuelo September 8, 2004 12:18 PM UTC

Hi, I am actually placing the summary columns in the group caption row so I modified the previous code to the following: if (e.TableCellIdentity.SummaryColumn != null && (e.Style.TableCellIdentity.DisplayElement is GridCaptionRow) ) e.Style.ReadOnly = false; I put a break and in debug mode I could see the code getting executed but the rows is still read only. When I click on any summary cell in that caption row it actually scrolls the grid all the way to the left row header. I guess that is built if functionality. Is there any way to make the summary fields editable if you are displaying them on the group caption row?


AD Administrator Syncfusion Team September 9, 2004 12:02 AM UTC

Hi Erlly, it is currently hard coded in the TableControl.CurrentCellMoving handler that when you try to move the current cell to a caption row that it will then instead go to the first column. We will add an option in our source code to prevent this from happening. One idea what you could work-around this right now with existing code is to listen to TableControlCurrentCellMoving. In that event handler save the e.Inner.ColIndex to a field in your class and reapply that colIndex to e.Inner.ColIndex in the TableControlCurrentCellActivating event handler. TableControlCurrentCellActivating is raised after the TableControl.CurrentCellMoving changed the value. That''s why I think that should work. (But I haven''t tried it). Stefan


EB Erlly Bayuelo September 9, 2004 12:29 PM UTC

Hi Stefan, That does work. The only problem is that when I exit the cell either by tabbing or clicking on another cell the modified cell reverts back to the original value. Any ideas? It does go into gridDBGrouping_TableControlCurrentCellAcceptedChanges and I tried e.Inner.Cancel = false but that does not work. Thanks, Erlly


AD Administrator Syncfusion Team September 9, 2004 02:41 PM UTC

Ok, that get''s kind of tricky ... The GridGroup does not have the concept of saving values in it so you would have to derive from GridGroup and implement an array where you can save values. What you would have to do is to derive a GridEngine object and then override its CreateGroupCaption method (as shown in GroupingPerf example). You also have to derive from GridCaptionRow and in your derived class implement the IGridTableCellStyleChanged interface. The IGridTableCellStyleChanged.RaiseTableCellStyleChanged method is called when the cells contents need to be stored away. You should save the change into your array at that time. In QueryCellStyleInfo then you need to retrieve the value from your array and assign it e.Style.CellValue. Stefan


EB Erlly Bayuelo September 9, 2004 05:55 PM UTC

Stefan, I could not find the CreateGroupCaption method you mentioned so I assumed you meant CreateCaptionRow()..below is what I got so far but I cannot seem to find a CreateGridGroup method to override. I plan to have my storage array be a member of my CustomGridGroup. public class GroupingEngineFactory : GridEngineFactoryBase { public override GridEngine CreateEngine() { return new GroupingEngine(); } } public class GroupingEngine : GridEngine { public override Syncfusion.Grouping.CaptionRow CreateCaptionRow(Syncfusion.Grouping.CaptionSection parent) { return new CustomCaptionRow(parent); } // cannot override because it does not exists //public override Syncfusion.Windows.Forms.Grid.Grouping.GridGroup CreateGridGroup(Syncfusion.Grouping.CaptionSection parent) //{ // return new CustomGridGroup(); //} } // If I subclass GridGroup how does it get created public class CustomGridGroup : Syncfusion.Windows.Forms.Grid.Grouping.GridGroup { public CustomGridGroup (Syncfusion.Grouping.Section parent): base(parent) { } } public class CustomCaptionRow : Syncfusion.Grouping.CaptionRow, IGridTableCellStyleChanged { public CustomCaptionRow(Syncfusion.Grouping.CaptionSection parent) : base(parent) { } #region IGridTableCellStyleChanged Members public void RaiseTableCellStyleChanged(GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.SummaryColumn != null && (e.Style.TableCellIdentity.DisplayElement is GridCaptionRow) ) ; // TODO: Add CustomCaptionRow.RaiseTableCellStyleChanged implementation // Save to storage array in GridGroup } #endregion }


AD Administrator Syncfusion Team September 9, 2004 06:14 PM UTC

Erlly, that was my mistake. I did of course mean CreateCaptionRow. With regards to creating a custom GridGroup you need to override the CreateGroup method. public override Group CreateGroup(Section parent) { return new CustomGridGroup(); } However, there is one complication with having the storage in the derived GridGroup that you should be aware of. A TopLevelGroup is a Syncfusion.Grouping.ChildTable (which is derived from Syncfusion.Grouping.Group) Nested groups are of type Syncfusion.Grouping.Group. ChildTable derives from Group, but when you derive from GridGroup you also need to derive a separate class from GridChildTable and thus also override CreateChildTable: public override ChildTable CreateChildTable(Element parent) { return new CustomGridChildTable(parent); } and in your CustomGridChildTable you''ll have to duplicate the code you put in CustomGridGroup. (I don''t like that design but we never found a way to do it better ... The reason behind having separate ChildTable and Group classes is that for nested groups you don''t need all the functionality that is in ChildTable and it would be not memory efficient to have one class that could be used for both childtables and nested groups.) Stefan


EB Erlly Bayuelo September 10, 2004 05:53 PM UTC

Hi Stefan, Thanks a lot for your help! I got it working. I am able to modify a summary column in my group caption row. I am enclosing a snippet from my QueryCellStyleInfo just to double check that I am going about populating the modified cell the right way. In my example the summary column is "QuoteValue" and the member of my derived CustomGridGroup where I am storing the modified value [from the newly implemented CustomCaptionRow.RaiseTableCellStyleChanged() method] is CustomGridGroup.CustomQuote (string) if (e.Style.TableCellIdentity.DisplayElement is CustomCaptionRow ) { e.Style.ReadOnly = false; if(e.TableCellIdentity.SummaryColumn != null && e.TableCellIdentity.SummaryColumn.DataMember == "QuoteValue") e.Style.CellValue = ((MaraUI.Forms.CustomGridGroup) ((CustomCaptionRow) e.Style.TableCellIdentity.DisplayElement).ParentGroup).CustomQuote ; } Thanks again, Erlly


AD Administrator Syncfusion Team September 10, 2004 06:28 PM UTC

Hi Erlly, yes, your QueryCellStyleInfo looks the right way to populate the value. Glad you got it working. Stefan


AA Anthony Avella November 18, 2004 12:51 PM UTC

Stefan, Is it possible for us to keep a copy of the previous value in the summary cell? We''d like to be able to restore the summary cell to the previous value, if we determine the new value breaks business rules. Thanks.


AD Administrator Syncfusion Team November 18, 2004 08:58 PM UTC

Hi Anthony, you can copy the old summary value before it is changed and keep it in an array within your element. You can do this at the same time before you save the changed value into your storage container. Stefan


AA Anthony Avella November 19, 2004 03:17 PM UTC

Stefan, Thank you. Next.... I''d like to use the new/updated value in the summary row column to update all of the detail records belonging to that summary row. I would also like the grid''s underlying datatable to be updated as well with the new value. How do I go about doing this? Anthony


AD Administrator Syncfusion Team November 19, 2004 08:32 PM UTC

That you have to do after you saved the value in your array and checked the business logic. You could then loop through ParentGroup.Records and foreach record call record.SetValue(fieldName, summaryValue). This will also store the value in the underlying datatable. Stefan


AA Anthony Avella November 23, 2004 11:30 AM UTC

Thanks >That you have to do after you saved the value in your array and checked the business logic. > >You could then loop through ParentGroup.Records and foreach record call record.SetValue(fieldName, summaryValue). This will also store the value in the underlying datatable. > >Stefan >


JO job September 3, 2006 02:31 AM UTC

can you guys post a sample project of this solution?

Loader.
Live Chat Icon For mobile
Up arrow icon