using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Syncfusion.Data;
using Syncfusion.WinForms.DataGrid;
using Syncfusion.WinForms.DataGrid.Enums;
using Syncfusion.WinForms.GridCommon;

namespace SyncfusionFilterCrash
{
	public partial class Form1 : Form
	{
		GridAdapter[] prefilledList;

		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			grid.AllowFiltering = true;
			//grid.AutoGenerateColumns = false;
			//grid.Columns.Add(new GridNumericColumn() { MappingName = "ConnectionId", HeaderText = "Connection Id", Format = "#" });

			//Add a summary row at the bottom of the grid. 
			var tableSummary = new GridTableSummaryRow()
			{
				Name = "TableSummary",
				ShowSummaryInRow = true,
				Position = VerticalPosition.Bottom,
				CalculationUnit = SummaryCalculationUnit.AllRows,
				Title = "{CountSummary}"
			};

			var countSummary = new GridSummaryColumn()
			{
				Name = "CountSummary",
				SummaryType = SummaryType.CountAggregate,
				Format = "{Count} visible element",
				MappingName = "ConnectionId"
			};

			tableSummary.SummaryColumns.Add(countSummary);
			grid.TableSummaryRows.Add(tableSummary);



			prefilledList = Utils.GenerateData();
			grid.DataSource = prefilledList;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			grid.ClearFilters();
		}
	
	}
}
