protected override string GetCurrentFilterValueFromControl(TableCell cell) { try { if (cell.Controls.Count > 2) { if (cell.Controls[1] is DropDownList) { DropDownList ddlBoolFilter = cell.Controls[1] as DropDownList; return((ddlBoolFilter.SelectedValue == "All") ? String.Empty : ddlBoolFilter.SelectedValue); } if (cell.Controls[1] is IndDatePicker) { IndDatePicker datePicker = cell.Controls[1] as IndDatePicker; return((datePicker.SelectedDate == null) ? String.Empty : ((DateTime)datePicker.SelectedDate).ToShortDateString()); } } return(base.GetCurrentFilterValueFromControl(cell)); } catch (IndException ex) { ControlHierarchyManager.ReportError(ex); return(null); } catch (Exception ex) { ControlHierarchyManager.ReportError(new IndException(ex)); return(null); } }
/// <summary> /// Adds a RadDatePicker control to the header of this column /// </summary> /// <param name="cell"></param> private void AddDateFilter(TableCell cell) { IndDatePicker datePicker = new IndDatePicker(); datePicker.ID = "pk" + this.UniqueName; datePicker.Width = Unit.Pixel(80); cell.Controls.Add(datePicker); }
private void DecreaseColumnWidths(int gridWidth) { int colMinWidth = 100; int widthDiff = gridWidth - GRID_MAX_WIDTH; //Calculate the number of visible bound columns int noBoundWideColumns = 0; foreach (GridColumn column in this.Columns) { if (column is IndGridBoundColumn && column.Display && column.HeaderStyle.Width.Value > colMinWidth) { noBoundWideColumns++; } } //The width in pixels by which the columns must be adjusted int colWidthDiff = widthDiff / noBoundWideColumns + 1; foreach (GridColumn column in this.Columns) { if (column is IndGridBoundColumn && column.Display && column.HeaderStyle.Width.Value > colMinWidth) { column.HeaderStyle.Width = Unit.Pixel((int)column.HeaderStyle.Width.Value - colWidthDiff); GridFilteringItem filterItem = (GridFilteringItem)this.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; TableCell filterCell = filterItem[column.UniqueName]; if (filterCell.Controls.Count == 2) { TextBox filterTextBox = filterCell.Controls[0] as TextBox; if (filterTextBox != null) { filterTextBox.Width = Unit.Pixel((int)filterTextBox.Width.Value - colWidthDiff); } } if (filterCell.Controls.Count == 3) { if (filterCell.Controls[1] is DropDownList) { DropDownList filterDdl = filterCell.Controls[1] as DropDownList; filterDdl.Width = Unit.Pixel((int)filterDdl.Width.Value - colWidthDiff); } if (filterCell.Controls[1] is IndDatePicker) { IndDatePicker filterDatePicker = filterCell.Controls[1] as IndDatePicker; filterDatePicker.Width = Unit.Pixel((int)filterDatePicker.Width.Value - colWidthDiff); } } } } }
protected override void SetCurrentFilterValueToControl(TableCell cell) { try { //SetCurrentFilterValueFromFilterExpression(); if (((IndCatGrid)this.Owner.OwnerGrid).IndFilterItem != null) { IndFilterItem indFilterItem = ((IndCatGrid)this.Owner.OwnerGrid).IndFilterItem; if (indFilterItem.FilterValues.ContainsKey(this.UniqueName)) { this.CurrentFilterValue = indFilterItem.FilterValues[this.UniqueName].ToString(); } } base.SetCurrentFilterValueToControl(cell); if (cell.Controls.Count > 2) { if (cell.Controls[1] is DropDownList) { DropDownList ddlBoolFilter = cell.Controls[1] as DropDownList; if (this.CurrentFilterValue != String.Empty) { ddlBoolFilter.SelectedValue = this.CurrentFilterValue; } } if (cell.Controls[1] is IndDatePicker) { IndDatePicker datePicker = cell.Controls[1] as IndDatePicker; if (!String.IsNullOrEmpty(this.CurrentFilterValue)) { datePicker.SelectedDate = DateTime.Parse(this.CurrentFilterValue); } } } } catch (IndException ex) { ControlHierarchyManager.ReportError(ex); return; } catch (Exception ex) { ControlHierarchyManager.ReportError(new IndException(ex)); return; } }
private void FilterSpecialColumn(IndGridBoundColumn col, IndFilterItem filterItem, string comparerStart, string comparerEnd, GridKnownFunction function) { if (col.Cell.Controls[1] is DropDownList) { DropDownList d = (DropDownList)col.Cell.Controls[1]; if (filterItem.FilterExpression.Length == 0) { filterItem.FilterExpression.Append("([" + col.UniqueName + "] " + comparerStart + ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue) + comparerEnd); } else { filterItem.FilterExpression.Append(" AND [" + col.UniqueName + "] " + comparerStart + ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue) + comparerEnd); } col.CurrentFilterFunction = function; col.CurrentFilterValue = ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue); filterItem.FilterValues.Add(col.UniqueName, (d.SelectedValue == "All") ? String.Empty : d.SelectedValue); } if (col.Cell.Controls[1] is IndDatePicker) { IndDatePicker datePicker = (IndDatePicker)col.Cell.Controls[1]; if (datePicker.SelectedDate != null) { if (filterItem.FilterExpression.Length == 0) { filterItem.FilterExpression.Append("([" + col.UniqueName + "] >= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 00:00:00.000' AND " + "[" + col.UniqueName + "] <= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 23:59:59.999'"); } else { filterItem.FilterExpression.Append(" AND [" + col.UniqueName + "] >= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 00:00:00.000' AND " + "[" + col.UniqueName + "] <= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 23:59:59.999'"); } } col.CurrentFilterFunction = function; col.CurrentFilterValue = (datePicker.SelectedDate != null) ? ((DateTime)datePicker.SelectedDate).ToShortDateString() : null; filterItem.FilterValues.Add(col.UniqueName, (datePicker.SelectedDate != null) ? ((DateTime)datePicker.SelectedDate).ToShortDateString() : String.Empty); } }