void InitDetailsAndPageHeader(ASPxGridView aspxGridView1) { ReadOnlyCollection<GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); int pagewidth = (report.PageWidth - (report.Margins.Left + report.Margins.Right)) - groupedColumns.Count * subGroupOffset; List<ColumnInfo> columns = GetColumnsInfo(aspxGridView1, pagewidth); CustomizeColumnsCollection(report, new ColumnsCreationEventArgs(pagewidth) { ColumnsInfo = columns }); report.Bands.Add(new DetailBand() { HeightF = bandHeight }); report.Bands.Add(new PageHeaderBand() { HeightF = bandHeight }); XRTable headerTable = new XRTable(); XRTableRow row = new XRTableRow(); XRTable detailTable = new XRTable(); XRTableRow row2 = new XRTableRow(); for (int i = 0; i < columns.Count; i++) { if (columns[i].IsVisible) { XRTableCell cell = new XRTableCell(); cell.Width = columns[i].ColumnWidth; cell.Text = columns[i].FieldName; row.Cells.Add(cell); XRTableCell cell2 = new XRTableCell(); cell2.Width = columns[i].ColumnWidth; ControlCustomizationEventArgs cc = new ControlCustomizationEventArgs() { FieldName = columns[i].FieldName, IsModified = false, Owner = cell2 }; CustomizeColumn(report, cc); if (cc.IsModified == false) cell2.DataBindings.Add("Text", null, columns[i].FieldName); detailsInfo.Add(columns[i].GridViewColumn, cell2); row2.Cells.Add(cell2); } } headerTable.Rows.Add(row); headerTable.Width = pagewidth; headerTable.LocationF = new PointF(groupedColumns.Count * subGroupOffset, 0); headerTable.Borders = BorderSide.Bottom; detailTable.Rows.Add(row2); detailTable.LocationF = new PointF(groupedColumns.Count * subGroupOffset, 0); detailTable.Width = pagewidth; report.Bands[BandKind.PageHeader].Controls.Add(headerTable); report.Bands[BandKind.Detail].Controls.Add(detailTable); }
private void HandleGridCallback(string parameter) { string[] parameters = parameter.Split(':'); string target = parameters[0]; string eventArgument = parameters[1]; bool eventArgumentIsTrue = eventArgument == "true"; switch (target) { case "PageSize": state.PageSize = ChildGrid.SettingsPager.PageSize = Convert.ToInt32(eventArgument); break; case "Grouping": ReadOnlyCollection <GridViewDataColumn> groupedColumns = ChildGrid.GetGroupedColumns(); foreach (GridViewDataColumn column in groupedColumns) { ChildGrid.UnGroup(column); } state.ShowGroupPanel = ChildGrid.Settings.ShowGroupPanel = eventArgumentIsTrue; break; case "Sorting": ChildGrid.ClearSort(); state.AllowSort = ChildGrid.SettingsBehavior.AllowSort = eventArgumentIsTrue; break; case "Filtering": ChildGrid.FilterExpression = String.Empty; state.ShowFilterRow = ChildGrid.Settings.ShowFilterRow = eventArgumentIsTrue; break; } ChildGrid.DataBind(); }
void Find(ASPxGridView gridView, string text, int rowIndex, int colIndex) { ReadOnlyCollection <GridViewDataColumn> groupedColumns = gridView.GetGroupedColumns(); for (int row = rowIndex; row < gridView.VisibleRowCount; row++) { for (int col = (row == rowIndex) ? colIndex : 0; col < gridView.Columns.Count; col++) { GridViewDataColumn dataColumn = gridView.Columns[col] as GridViewDataColumn; if (dataColumn != null && dataColumn.Visible) { object cellValue = gridView.GetRowValues(row, dataColumn.FieldName); if (cellValue != null && cellValue.ToString().Contains(text)) { if ((gridView.GetRowLevel(row) == groupedColumns.Count && !groupedColumns.Contains(dataColumn)) || //Is data row cell (gridView.IsGroupRow(row) && gridView.GetRowLevel(row) == dataColumn.GroupIndex)) //Is group row of the current dataColumn { gridView.MakeRowVisible(gridView.GetRowValues(row, gridView.KeyFieldName)); gridView.JSProperties["cpFindText"] = text; gridView.JSProperties["cpFindPositionRow"] = row; gridView.JSProperties["cpFindPositionColumn"] = col + 1; gridView.JSProperties["cpFindSomehting"] = true; return; } } } } } gridView.JSProperties["cpFindPositionRow"] = 0; gridView.JSProperties["cpFindPositionColumn"] = 0; gridView.JSProperties["cpFindSomehting"] = false; }
/// <summary> /// 对 DX GridView 的扩展:为传入的 Q 加载 OrderBy ThenBy OrderDescendingBy ... /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gv"></param> /// <param name="q"></param> /// <returns></returns> public static IQueryable <T> ApplySorts <T>(this ASPxGridView gv, IQueryable <T> q, bool processGroup = false, bool groupAsc = true) { var columns = gv.GetSortedColumns(); var gColumns = gv.GetGroupedColumns(); List <KeyValuePair <string, bool> > sorts = new List <KeyValuePair <string, bool> >(); foreach (var c in columns.OrderBy(cc => cc.SortIndex)) { var asc = true; if (c.SortOrder == DevExpress.Data.ColumnSortOrder.Descending) { asc = false; } var gC = gColumns.SingleOrDefault(cc => cc.FieldName == c.FieldName); if (processGroup) { if (gC != null) { asc = groupAsc; } } else { if (gC != null) { continue; } } sorts.Add(new KeyValuePair <string, bool>(c.FieldName, asc)); } return(Exp.AppendSorts <T>(q, sorts.ToArray())); }
void InitGroupSummaries(ASPxGridView aspxGridView1) { if (aspxGridView1.GroupSummary.Count > 0) { ReadOnlyCollection <GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); for (int i = groupedColumns.Count - 1; i >= 0; i--) { GroupFooterBand footerBand = new GroupFooterBand(); footerBand.Height = bandHeight; report.Bands.Add(footerBand); footerBand.BackColor = Color.LightGray; foreach (ASPxSummaryItem item in aspxGridView1.GroupSummary) { GridViewColumn col = aspxGridView1.Columns[item.FieldName]; if (col != null) { if (detailsInfo.Contains(col)) { XRLabel label = new XRLabel(); label.LocationF = ((XRTableCell)detailsInfo[col]).LocationF; label.SizeF = ((XRTableCell)detailsInfo[col]).SizeF; label.DataBindings.Add("Text", null, ((GridViewDataColumn)col).FieldName); label.Summary = new XRSummary() { Running = SummaryRunning.Group }; label.Summary.FormatString = item.DisplayFormat; label.Summary.Func = GetSummaryFunc(item.SummaryType); footerBand.Controls.Add(label); } } } } } }
protected void grv_responsibility_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { if (e.RowType == GridViewRowType.Group) { ASPxGridView grid = sender as ASPxGridView; ASPxLabel groupname = grid.FindGroupRowTemplateControl(e.VisibleIndex, "lbl_groupname") as ASPxLabel; ReadOnlyCollection <GridViewDataColumn> groupcollection = grid.GetGroupedColumns(); foreach (GridViewDataColumn column in groupcollection) { groupname.Text = column.Caption + ": " + grid.GetRowValues(e.VisibleIndex, column.FieldName); } ASPxButton button = new ASPxButton(); } }
private object[] FindGroupValues(ASPxGridView grid) { grid.DataBind(); string column = grid.GetGroupedColumns()[0].FieldName; ArrayList list = new ArrayList(); for (int i = 0; i < grid.VisibleRowCount; i++) { if (grid.GetRowLevel(i) == 0) { list.Add(grid.GetRowValues(i, column)); } } return(list.ToArray()); }
void InitSortings(ASPxGridView aspxGridView1) { List <GridViewDataColumn> columns = GetVisibleDataColumns(aspxGridView1); ReadOnlyCollection <GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); for (int i = 0; i < columns.Count; i++) { if (!groupedColumns.Contains(columns[i])) { if (columns[i].SortOrder != ColumnSortOrder.None) { ((DetailBand)report.Bands[BandKind.Detail]).SortFields.Add(new GroupField(columns[i].FieldName, columns[i].SortOrder == ColumnSortOrder.Ascending ? XRColumnSortOrder.Ascending : XRColumnSortOrder.Descending)); } } } }
void InitGroupHeaders(ASPxGridView aspxGridView1) { ReadOnlyCollection <GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); for (int i = groupedColumns.Count - 1; i >= 0; i--) { { GridViewDataColumn groupedColumn = groupedColumns[i]; GroupHeaderBand gb = new GroupHeaderBand(); gb.Height = bandHeight; XRLabel l = new XRLabel(); l.Text = groupedColumn.FieldName + ": [" + groupedColumn.FieldName + "]"; l.LocationF = new PointF(initialGroupOffset + i * 10, 0); l.BackColor = Color.Beige; l.SizeF = new SizeF((report.PageWidth - (report.Margins.Left + report.Margins.Right)) - (initialGroupOffset + i * subGroupOffset), bandHeight); gb.Controls.Add(l); gb.RepeatEveryPage = shouldRepeatGroupHeadersOnEveryPage; GroupField gf = new GroupField(groupedColumn.FieldName, groupedColumn.SortOrder == ColumnSortOrder.Ascending ? XRColumnSortOrder.Ascending : XRColumnSortOrder.Descending); gb.GroupFields.Add(gf); report.Bands.Add(gb); } } }
void InitSortings(ASPxGridView aspxGridView1) { List<GridViewDataColumn> columns = GetVisibleDataColumns(aspxGridView1); ReadOnlyCollection<GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); for (int i = 0; i < columns.Count; i++) { if (!groupedColumns.Contains(columns[i])) { if (columns[i].SortOrder != ColumnSortOrder.None) ((DetailBand)report.Bands[BandKind.Detail]).SortFields.Add(new GroupField(columns[i].FieldName, columns[i].SortOrder == ColumnSortOrder.Ascending ? XRColumnSortOrder.Ascending : XRColumnSortOrder.Descending)); } } }
void InitGroupHeaders(ASPxGridView aspxGridView1) { ReadOnlyCollection<GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); for (int i = groupedColumns.Count - 1; i >= 0; i--) { { GridViewDataColumn groupedColumn = groupedColumns[i]; GroupHeaderBand gb = new GroupHeaderBand(); gb.Height = bandHeight; XRLabel l = new XRLabel(); l.Text = groupedColumn.FieldName + ": [" + groupedColumn.FieldName + "]"; l.LocationF = new PointF(initialGroupOffset + i * 10, 0); l.BackColor = Color.Beige; l.SizeF = new SizeF((report.PageWidth - (report.Margins.Left + report.Margins.Right)) - (initialGroupOffset + i * subGroupOffset), bandHeight); gb.Controls.Add(l); gb.RepeatEveryPage = shouldRepeatGroupHeadersOnEveryPage; GroupField gf = new GroupField(groupedColumn.FieldName, groupedColumn.SortOrder == ColumnSortOrder.Ascending ? XRColumnSortOrder.Ascending : XRColumnSortOrder.Descending); gb.GroupFields.Add(gf); report.Bands.Add(gb); } } }
public static List <string> GroupFieldNames(this ASPxGridView source) { return(source.GetGroupedColumns().Select(x => x.FieldName).ToList()); }
void InitDetailsAndPageHeader(ASPxGridView aspxGridView1) { ReadOnlyCollection <GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns(); int pagewidth = (report.PageWidth - (report.Margins.Left + report.Margins.Right)) - groupedColumns.Count * subGroupOffset; List <ColumnInfo> columns = GetColumnsInfo(aspxGridView1, pagewidth); if (CustomizeColumnsCollection != null) { CustomizeColumnsCollection(report, new ColumnsCreationEventArgs(pagewidth) { ColumnsInfo = columns }); } report.Bands.Add(new DetailBand() { HeightF = bandHeight }); report.Bands.Add(new PageHeaderBand() { HeightF = bandHeight }); XRTable headerTable = new XRTable(); XRTableRow row = new XRTableRow(); XRTable detailTable = new XRTable(); XRTableRow row2 = new XRTableRow(); for (int i = 0; i < columns.Count; i++) { if (columns[i].IsVisible) { XRTableCell cell = new XRTableCell(); cell.Width = columns[i].ColumnWidth; cell.Text = columns[i].FieldName; row.Cells.Add(cell); XRTableCell cell2 = new XRTableCell(); cell2.Width = columns[i].ColumnWidth; ControlCustomizationEventArgs cc = new ControlCustomizationEventArgs() { FieldName = columns[i].FieldName, IsModified = false, Owner = cell2 }; if (CustomizeColumn != null) { CustomizeColumn(report, cc); } if (cc.IsModified == false) { cell2.DataBindings.Add("Text", null, columns[i].FieldName); } detailsInfo.Add(columns[i].GridViewColumn, cell2); row2.Cells.Add(cell2); } } headerTable.Rows.Add(row); headerTable.Width = pagewidth; headerTable.LocationF = new PointF(groupedColumns.Count * subGroupOffset, 0); headerTable.Borders = BorderSide.Bottom; detailTable.Rows.Add(row2); detailTable.LocationF = new PointF(groupedColumns.Count * subGroupOffset, 0); detailTable.Width = pagewidth; report.Bands[BandKind.PageHeader].Controls.Add(headerTable); report.Bands[BandKind.Detail].Controls.Add(detailTable); }