When I add a new group to the droparea,I want to sort all the groups' caption by the group's record count ,can anyone give me a sample? |
In order to sort the groups based on the record count, you can use the CustomGroupComparer which is derived from IGroupSortOrderComparer. Please refer the below code snippet and attached sample.
Code snippet:
sortColumn.GroupSortOrderComparer = new CustomGroupComparer();
public class CustomGroupComparer : IGroupSortOrderComparer
{
public int Compare(object x, object y)
{
Syncfusion.Grouping.Group gx = (Syncfusion.Grouping.Group)x;
Syncfusion.Grouping.Group gy = (Syncfusion.Grouping.Group)y;
int gxRecordCount = gx.GetRecordCount();
int gyRecordCount = gy.GetRecordCount();
return gyRecordCount - gxRecordCount;
}
/// <summary>For internal use.
/// Get the dependantFields.
/// </summary>
/// <param name="td">The table descriptor.</param>
/// <returns>Returns the array of descriptor names.</returns>
public string[] GetDependantFields(TableDescriptor td)
{
return new string[] { };
}
} |
I bind a datatable to a ggc,when the ggc without any group,I select a row.how to get the row's all part ,
for expmple,every column's value,name,and the index of in the orginal datatable?
|
The reported scenario can be achieved by handling the CellClick event. Please refer the below code snippet and attached sample
Code snippet:
void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
//Record value
Record record = style.TableCellIdentity.DisplayElement.GetRecord();
//Column value
String value = record.GetValue("Id").ToString();
//Column name
String columnName=style.TableCellIdentity.Column.Name;
//Record index
int index = style.TableCellIdentity.DisplayElement.GetRowIndex();
GridTableCellStyleInfoIdentity id = style.TableCellIdentity;
if (id.DisplayElement.Kind == DisplayElementKind.Record)
{
Record rec = id.DisplayElement.GetRecord();
int actualIndex = rec.Id;//Real RowIndex
}
} |