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> /// 显示行数 /// </summary> /// <returns></returns> public Decorator ShowRowNumber(int index = 0) { var c = new GridViewDataTextColumn() { Name = "rn", Caption = "#", ReadOnly = true, VisibleIndex = index, UnboundType = DevExpress.Data.UnboundColumnType.String, Width = 35 }; c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; c.CellStyle.HorizontalAlign = HorizontalAlign.Right; c.CellStyle.VerticalAlign = VerticalAlign.Middle; c.CellStyle.ForeColor = System.Drawing.Color.Gray; c.Settings.AllowAutoFilter = DevExpress.Utils.DefaultBoolean.False; c.Settings.AllowAutoFilterTextInputTimer = DevExpress.Utils.DefaultBoolean.False; c.Settings.AllowDragDrop = DevExpress.Utils.DefaultBoolean.False; c.Settings.AllowGroup = DevExpress.Utils.DefaultBoolean.False; c.Settings.AllowHeaderFilter = DevExpress.Utils.DefaultBoolean.False; c.Settings.AllowSort = DevExpress.Utils.DefaultBoolean.False; _Grid.Columns.Insert(index, c); _Grid.CustomColumnDisplayText += (s, e) => { if (! _Grid.IsGroupRow(e.VisibleRowIndex) && e.Column.VisibleIndex == index && e.Column.Name == "rn") { int groupCount = 0; for (int i = 0; i < e.VisibleRowIndex; i++) { if (_Grid.IsGroupRow(i)) { groupCount++; } } e.DisplayText = (e.VisibleRowIndex + 1 - groupCount).ToString(); } }; return(this); }
private static void CollectGroupIndexes(ASPxGridView g) { groupIndexes.Clear(); for (int i = 0; i < g.VisibleRowCount; i++) { if (g.IsGroupRow(i)) { groupIndexes.Add(i); } } }
protected void grid_BeforeGetCallbackResult(object sender, EventArgs e) { ASPxGridView g = sender as ASPxGridView; for (int i = 0; i < g.VisibleRowCount; i++) { if (g.IsGroupRow(i) && !g.IsRowExpanded(i) && g.GetRowLevel(i) > 0) { g.ExpandRow(i, true); } } }
protected List <int> GetVisibleChildDataRowIndices(ASPxGridView grid, int groupVisibleIndex, out int grouppedRowsCount, out int checkedInvisibleIndecesCount, out int checkedVisibleIndecesCount, out CheckState checkState) { var result = new List <int>(); var groupLevel = grid.GetRowLevel(groupVisibleIndex); var visibleStart = grid.VisibleStartIndex; var visibleEnd = visibleStart + Math.Min(grid.VisibleRowCount - visibleStart, grid.SettingsPager.PageSize) - 1; var visibleIndex = groupVisibleIndex + 1; grouppedRowsCount = 0; checkedInvisibleIndecesCount = 0; checkedVisibleIndecesCount = 0; while (grid.GetRowLevel(visibleIndex) > groupLevel) { var checkValue = (bool)grid.GetRowValues(visibleIndex, GroupCheckBoxFieldName); if (!grid.IsGroupRow(visibleIndex) && ((visibleIndex >= visibleStart && visibleIndex <= visibleEnd) && grid.GetRowLevel(visibleIndex) != groupLevel)) { if (checkValue) { checkedVisibleIndecesCount++; } result.Add(visibleIndex); } else { if (checkValue) { checkedInvisibleIndecesCount++; } } visibleIndex++; grouppedRowsCount++; } checkState = GetCheckState(checkedVisibleIndecesCount + checkedInvisibleIndecesCount, grouppedRowsCount); return(result); }
public static int GetDataRowCount(this ASPxGridView source) { var smartDataSource = source.DataSource as ISmartDataSourse; if (smartDataSource != null) { return(smartDataSource.Count); } if (source.IsGrouped()) { var result = 0; for (var index = 0; index < source.VisibleRowCount; index++) { if (source.IsGroupRow(index)) { if (source.IsRowExpanded(index) == false) { var keys = (source.DataBoundProxy).GetChildKeysRecursive(index); result += keys.Cast <object>().Count(x => x != null); } } else { result++; } } return(result); } return(source.VisibleRowCount); }
private static bool IsRowIsFirstGroup(int index, ASPxGridView g) { return(g.IsGroupRow(index - 1)); }