Get sum of selected cell thru checkbox and save to string
hi Gents,
Attachment: getsum_5921e65e.7z
What I want to do is to select an object thru checkbox in sfdatagrid and those selected object will give me the total and save into string.
please see attached screenshot for more information.
will this be possible?
thank you
Attachment: getsum_5921e65e.7z
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
VS
Vijayarasan Sivanandham
Syncfusion Team
September 7, 2020 09:46 AM UTC
Hi Mark Jayvee,
Thank you for contacting Syncfusion Support.
By default, SfDataGrid allows you to select or deselect individual rows through CheckBox using GridCheckBoxSelectorColumn. You can get the summaries of checkbox clicked rows by using SfDataGrid.SummaryCalculationUnit or GridSummaryRow.CalculationUnit property. Please refer the below code snippet for your reference,
Thank you for contacting Syncfusion Support.
By default, SfDataGrid allows you to select or deselect individual rows through CheckBox using GridCheckBoxSelectorColumn. You can get the summaries of checkbox clicked rows by using SfDataGrid.SummaryCalculationUnit or GridSummaryRow.CalculationUnit property. Please refer the below code snippet for your reference,
|
sfDataGrid1.SelectionMode = GridSelectionMode.Multiple;
this.sfDataGrid1.Columns.Add(new GridCheckBoxSelectorColumn() { MappingName = "IsChecked", HeaderText = "IsChecked", Width = 100, CheckBoxSize = new Size(14, 14) });
// Creates the TableSummaryRow1.
GridTableSummaryRow tableSummaryRow1 = new GridTableSummaryRow();
tableSummaryRow1.ShowSummaryInRow = false;
tableSummaryRow1.Position = VerticalPosition.Top;
tableSummaryRow1.CalculationUnit = SummaryCalculationUnit.SelectedRows;
// Creates the GridSummaryColumn1.
GridSummaryColumn summaryColumn1 = new GridSummaryColumn();
summaryColumn1.Name = "Volume";
summaryColumn1.Format = "Total Volume : {Sum}";
summaryColumn1.MappingName = "Volume";
summaryColumn1.SummaryType = SummaryType.DoubleAggregate;
// Creates the GridSummaryColumn2.
GridSummaryColumn summaryColumn2 = new GridSummaryColumn();
summaryColumn2.Name = "Area";
summaryColumn2.Format = "Total Area : {Sum}";
summaryColumn2.MappingName = "Area";
summaryColumn2.SummaryType = SummaryType.DoubleAggregate;
// Adds the GridSummaryColumn in the SummaryColumns collection.
tableSummaryRow1.SummaryColumns.Add(summaryColumn1);
tableSummaryRow1.SummaryColumns.Add(summaryColumn2);
// Adds the GridTableSummaryRow in the TableSummaryRows collection.
this.sfDataGrid1.TableSummaryRows.Add(tableSummaryRow1); |
Screenshot for your reference,
Sample Link: https://www.syncfusion.com/downloads/support/forum/157602/ze/SelectedValueSum-1037026795
UG Link: https://help.syncfusion.com/windowsforms/datagrid/columntypes#gridcheckboxselectorcolumn
We hope this helps. Please let us know, if you require further assistance on this.
Regards,
Vijayarasan S
Regards,
Vijayarasan S
MJ
Mark Jayvee
September 7, 2020 07:38 PM UTC
Hi thank you for the response.
For the sum, how can I store that to string?
Like string vol=
Cheers,
Mark
VS
Vijayarasan Sivanandham
Syncfusion Team
September 8, 2020 01:44 PM UTC
Hi Mark Jayvee,
Thanks for the update.
You requirement can achieved by using the SummaryCreator.GetSummaryDisplayText method when GridSummaryRow.ShowSummaryInRow is false.
Thanks for the update.
You requirement can achieved by using the SummaryCreator.GetSummaryDisplayText method when GridSummaryRow.ShowSummaryInRow is false.
|
private void button1_Click(object sender, EventArgs e)
{
txtArea.Text = SummaryCreator.GetSummaryDisplayText(sfDataGrid1.View.Records.TableSummaries[0], "Area", sfDataGrid1.View);
txtVolume.Text = SummaryCreator.GetSummaryDisplayText(sfDataGrid1.View.Records.TableSummaries[0], "Volume", sfDataGrid1.View);
} |
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/157602/ze/StoreSummaryValue-1046352094
We hope this helps. Please let us know, if you require further assistance on this.
Regards,
Vijayarasan s
Regards,
Vijayarasan s
Marked as answer
MJ
Mark Jayvee
September 10, 2020 09:35 AM UTC
thank you for the response. this works fine.
VS
Vijayarasan Sivanandham
Syncfusion Team
September 11, 2020 09:31 AM UTC
Hi Mark Jayvee,
Thanks for the update.
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.
Regards,
Vijayarasan S
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
- Marked answer
-
MJ Mark Jayvee
- Sep 5, 2020 10:39 AM UTC
- Sep 11, 2020 09:31 AM UTC