/// <summary> /// /// </summary> /// <param name="parentColumn"></param> /// <returns></returns> protected override Cell CreateCell(Column parentColumn) { FilterCell cell = new FilterCell(parentColumn); cell.ReadOnly = false; return(cell); }
private void InitFilterLists() { try { // Only build the list from the values under the FilterRow's hierarchical position. GroupBase groupBase = this.ParentGroup; ReadOnlyDataRowList dataRows = groupBase.GetSortedDataRows(true); //int dataRowsCount = dataRows.Count; DetailGrid parentGrid = groupBase as DetailGrid; if (parentGrid == null) { parentGrid = groupBase.ParentGrid; } int cellsCount = parentGrid.Columns.Count; // Clear the existing lists. for (int i = 0; i < cellsCount; i++) { FilterCell filterCell = (FilterCell)this.Cells[i]; if (filterCell.Visible) { filterCell.FillFilterList(); } } //for (int i = 0; i < dataRowsCount; i++) //{ // DataRow dataRow = dataRows[i]; // for (int j = 0; j < cellsCount; j++) // { // FilterCell filterCell = (FilterCell)this.Cells[j]; // // If the cell is Visible, add its value to the list. // if (filterCell.Visible) // filterCell.AddToFilterList(dataRow.Cells[j]); // } //} } catch (Exception ex) { throw new GridException("An error occured while filling the FilterRow's filter list.", ex); } }
/// <summary> /// /// </summary> /// <param name="template"></param> public FilterCell(FilterCell template) : base(template) { }
/// <summary> /// /// </summary> /// <param name="parentColumn"></param> /// <returns></returns> protected override Cell CreateCell(Column parentColumn) { FilterCell cell = new FilterCell(parentColumn); cell.ReadOnly = false; return cell; }
/// <summary> /// /// </summary> public void ApplyFilters() { if (!this.Enabled) { return; } GroupBase parentGroup = this.ParentGroup; if (parentGroup == null) { return; } ReadOnlyDataRowList siblingDataRows = parentGroup.GetSortedDataRows(true); int siblingDataRowsCount = siblingDataRows.Count; int cellsCount = this.Cells.Count; for (int i = 0; i < siblingDataRowsCount; i++) { DataRow dataRow = siblingDataRows[i]; bool rowMatchesFilter = true; for (int j = 0; j < cellsCount; j++) { if (!this.Cells[j].Visible) { continue; } FilterCell filterCell = (FilterCell)this.Cells[j]; IFilter filter = filterCell.GetFilter(); //object cellValue = dataRow.Cells[j].Value; if (filter != null) { rowMatchesFilter = filter.Evaluate(dataRow.Cells[j].CellViewerManager is INameValueControl ? dataRow.Cells[j].GetDisplayText() : dataRow.Cells[j].Value); } if (!rowMatchesFilter) { break; } } dataRow.Visible = rowMatchesFilter; // If the row belongs to a group, set the group visibility accordingly to its rows visibility. // The group will be hidden if all of its dataRows are filtered out. // If at least one dataRow is visible, then the group should also be visible. Group dataRowParentGroup = dataRow.ParentGroup as Group; if (dataRowParentGroup != null) { if (rowMatchesFilter) { MakeParentGroupsVisible(dataRowParentGroup); } else { MakeParentGroupsInvisibleIfNoRowsVisible(dataRowParentGroup); } } } RaiseFilteredEvent(); }