BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
this.gridGroupingControl1.TableDescriptor.Columns["Date"].Appearance.AnyCell.CellValueType = typeof(DateTime);
this.gridGroupingControl1.TableDescriptor.Columns["Date"].Appearance.AnyCell.Format = "MMM-yyyy";
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null)
{
GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow;
string date="";
DateTime dt;
if (e.Style.Text != null && DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8),out dt))
{
date = dt.ToString("MMM-yyyy");
}
e.Style.CellValue = String.Format("{0}: {1} Items.", date, e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount());
}
}
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/WindowsFormsApplication21_(7)-3092278901853385473.zip
Thanks & Regards,
AL.Solai
Hi Felipe,
Sorry for the inconvenience.
By default our grid grouping control support only string sorting. For your case you need to use Custom sorting using IComparer and handle that in SortedColumns.Changing event with the following code. Please refer the below sample and code snippet for further clarification.
Code Snippet[c#]:
gridGroupingControl1.TableDescriptor.SortedColumns.Changing += new Syncfusion.Collections.ListPropertyChangedEventHandler(SortedColumns_Changing);
void SortedColumns_Changing(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
SortColumnDescriptor sd = e.Item as SortColumnDescriptor;
if (sd != null && e.Action == Syncfusion.Collections.ListPropertyChangedType.Add)
{
Type type = this.gridGroupingControl1.TableDescriptor.Columns[sd.Name].Appearance.AnyRecordFieldCell.CellValueType;
if (sd.Name == "Date" && type == typeof(DateTime))
sd.Comparer = new DateComparer();
}
}
public class DateComparer : IComparer
{
public DateComparer() { }
public int Compare(object x, object y)
{
DateTime value1 = DateTime.Parse(x.ToString());
DateTime value2 = DateTime.Parse(y.ToString());
return DateTime.Compare(value1,value2);
}
}
Sample:
Please let us know if you have any other concerns.
Thanks & Regards,
AL.Solai.