Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141526 | Dec 15,2018 08:21 PM UTC | Jan 17,2020 10:55 AM UTC | WinForms | 11 |
![]() |
Tags: GridGroupingControl |
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity == null)
return;
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null)
{
GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow;
var style = this.gridGroupingControl1.TableDescriptor.Columns[e.TableCellIdentity.GroupedColumn.Name].Appearance.AnyRecordFieldCell;
if (style != null)
{
var data = style.DataSource as DataTable;
if(data != null)
{
var row = data.Select("[" + style.ValueMember + "] = '" + e.TableCellIdentity.DisplayElement.ParentGroup.Category + "'");
if (row != null)
{
string displayMember = row[0][style.DisplayMember].ToString();
e.Style.CellValue = String.Format("{0}:{1}-{2} items", e.TableCellIdentity.GroupedColumn.Name, displayMember, e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount());
}
}
}
}
} |
var row = data.Select("[" + style.ValueMember + "] = '" + e.TableCellIdentity.DisplayElement.ParentGroup.Category + "'");
if (row != null && row.Length > 0)
{
string displayMember = row[0][style.DisplayMember].ToString();
e.Style.CellValue = String.Format("{0}:{1}-{2} items", e.TableCellIdentity.GroupedColumn.Name, displayMember, e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount());
} |
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity == null)
return;
//select datasource for the Major code comboboxes
if (e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "Ship City"
&& e.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record)
{
// Gets the value selected from the combobox.
//string divisionID = e.TableCellIdentity.DisplayElement.GetRecord().GetValue("EstDataDivision").ToString();
//string Fillquerry = "SELECT MajorID, CONCAT(RTRIM(MajorID), ' - ',RTRIM(MajorDescription)) AS Description FROM dbo.CodeMajor WHERE DivisionID='" + divisionID + "'";
//DataTable MajorDT = Dbo.ReturnDataTable(Fillquerry, Properties.Settings.Default.DBConnString);
e.TableCellIdentity.Column.Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.ComboBox;
e.TableCellIdentity.Column.Appearance.AnyRecordFieldCell.DataSource = MajorDT;
e.TableCellIdentity.Column.Appearance.AnyRecordFieldCell.DisplayMember = "Description";
e.TableCellIdentity.Column.Appearance.AnyRecordFieldCell.ValueMember = "MajorID";
}
//Do the Same for all combobox columns.
// code to update/change the DisplayMember as grouping name
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.