I am back for a another go at this and i hope that because i have upgraded to 18.1 i will get a better result
I have a working ICustomSummaryCalculator which adds an "Alway On" summary to my columns
Users would like this ICustomSummaryCalculator to be added as an option in your summary selector (activated via the sigma button)
Is there any way to do this that does not invole me writing a ton of replacement UI code that basicaly would emulate what you ahve already done
I saw some way to do it with some Web.UI version and some custom summary editor in ASP land so it got my hopes up for c#www.infragistics.com/.../webdatagrid-adding-custom-summary
If the answer is still NO could you tell me how to hide my ICustomSummaryCalculator with out removing itHINT - "SummarySettings.Hidden=false;" does not do anything, it still shows
All appendages crossed here
Bryan
Hi Bryan,
This is an interesting puzzle. The dialog itself is not made to be modifiable. There's no list of items you can add to.
But I don't think it would be too terribly difficult to write code that modifies the dialog and adds an additional Checkbox.
I took a brief shot at it, and it seems pretty straightforward. Here's the relevant code.
private void UltraGrid1_BeforeSummaryDialog(object sender, BeforeSummaryDialogEventArgs e) { // Find the controls we need on the existing dialog. Control summaryControl = e.SummaryDialog.Controls["SummaryControl"]; Control backgroundPanel = summaryControl.Controls["ultraBackgroundPanel"]; Control cancelUltraButton = backgroundPanel.Controls["cancelUltraButton"]; Control okUltraButton = backgroundPanel.Controls["okUltraButton"]; Control panelCheckboxes = backgroundPanel.Controls["panelCheckboxes"]; Control sumCheckBox = panelCheckboxes.Controls["sumCheckBox"]; // I am assuming that the application allows multiple summaries, so // the dialog is using CheckBoxes. For a single summary, it would use radio buttons // and you would need to use these two controls and change the code below to add // a RadioButton insetad of a CheckBox. // //Control panelRadios = backgroundPanel.Controls["panelRadios"]; //Control sumRadio = panelRadios.Controls["sumRadio"]; this.myCheckBox = new CheckBox(); this.myCheckBox.Name = "myCheckBox"; this.myCheckBox.Text = "My custom summary type"; this.myCheckBox.SetBounds( sumCheckBox.Left, sumCheckBox.Bottom + 4, sumCheckBox.Width, sumCheckBox.Height ); if (DoesCustomSummaryAlreadyExist(e.Column)) this.myCheckBox.Checked = true; // You will proabably want to add an image to the CheckBox here so it will look // consistent with the other checkboxes. //this.myCheckBox.Image = myImage; // The dialog and the controls need to be shifted and resized to accomodate // the new control. int heightAdjustment = this.myCheckBox.Height + 4; panelCheckboxes.Height += heightAdjustment; e.SummaryDialog.Height += heightAdjustment; okUltraButton.Top += heightAdjustment; cancelUltraButton.Top += heightAdjustment; panelCheckboxes.Controls.Add(myCheckBox); } private void UltraGrid1_AfterSummaryDialog(object sender, AfterSummaryDialogEventArgs e) { if (null != this.myCheckBox) { string myCustomSummaryKey = GetMyCustomSummaryKey(e.Column); bool customSummaryAlreadyExists = DoesCustomSummaryAlreadyExist(e.Column); if (this.myCheckBox.Checked && !customSummaryAlreadyExists) { // I used a Formula summary here as a placeholder so I didn't have to // create an ICustomSummaryCalculator. But you would use SummaryType.Custom // and use an overload of Summaries.Add that takes an ICustomSummaryCalculator. e.Column.Band.Summaries.Add(myCustomSummaryKey, SummaryType.Formula, e.Column); } else if (!this.myCheckBox.Checked && customSummaryAlreadyExists) { var ss = e.Column.Band.Summaries[myCustomSummaryKey]; e.Column.Band.Summaries.Remove(ss); } this.myCheckBox.Dispose(); this.myCheckBox = null; } } private bool DoesCustomSummaryAlreadyExist(UltraGridColumn column) { string myCustomSummaryKey = GetMyCustomSummaryKey(column); return column.Band.Summaries.Exists(myCustomSummaryKey); } private string GetMyCustomSummaryKey(UltraGridColumn column) { return string.Format("MyCustomSummaryColumn - {0}", column.Key); }
And I also attached a working sample.WinGrid - Custom Item on Summaryt Dialog.zip
Thank you very much I cant thank you enough
You saved me weeks as i cant devote alot of time to learning the ins and outs of infragistics UI enhancement :~)
I quickly converted the relevant parts to C++/CLI because im stuck in the 90's (code at the end for other people lsot in time)
Added my RMS ICustomSummaryCalculator logic and booom!
All i have to do now is all all the other ICustomSummaryCalculator's and im done
// Thanks to infragistics team void ultraGrid1_BeforeSummaryDialog(System::Object^ sender,Infragistics::Win::UltraWinGrid::BeforeSummaryDialogEventArgs^ e) { // Find the controls we need on the existing dialog. Control ^summaryControl=e->SummaryDialog->Controls["SummaryControl"]; Control ^backgroundPanel=summaryControl->Controls["ultraBackgroundPanel"]; Control ^cancelUltraButton=backgroundPanel->Controls["cancelUltraButton"]; Control ^okUltraButton=backgroundPanel->Controls["okUltraButton"]; Control ^panelCheckboxes=backgroundPanel->Controls["panelCheckboxes"]; Control ^sumCheckBox=panelCheckboxes->Controls["sumCheckBox"]; bool exists; myCheckBox=gcnew CheckBox(); myCheckBox->Name="myCheckBox"; myCheckBox->Text="Rms"; //myCheckBox.Image = myImage; myCheckBox->SetBounds(sumCheckBox->Left,sumCheckBox->Bottom+4,sumCheckBox->Width,sumCheckBox->Height); exists=e->Column->Band->Summaries->Exists("Rms"); if(exists)myCheckBox->Checked=true; // The dialog and the controls need to be shifted and resized to accomodate the new control. int heightAdjustment=myCheckBox->Height+4; panelCheckboxes->Height += heightAdjustment; e->SummaryDialog->Height += heightAdjustment; okUltraButton->Top += heightAdjustment; cancelUltraButton->Top += heightAdjustment; panelCheckboxes->Controls->Add(myCheckBox); } void ultraGrid1_AfterSummaryDialog(System::Object^ sender,Infragistics::Win::UltraWinGrid::AfterSummaryDialogEventArgs^ e) { OptimiseSummary ^os=gcnew OptimiseSummary(0); SummarySettings ^ss; bool exists; if(myCheckBox!=nullptr){ exists=e->Column->Band->Summaries->Exists("Rms"); if(myCheckBox->Checked && !exists){ ss=e->Column->Band->Summaries->Add( "Rms",SummaryType::Custom,os,e->Column, SummaryPosition::UseSummaryPositionColumn,e->Column ); ss->DisplayFormat="Rms = {0}"; }else if(!myCheckBox->Checked && exists){ ss=e->Column->Band->Summaries["Rms"]; e->Column->Band->Summaries->Remove(ss); } myCheckBox=nullptr; } }