Hey everyone,
I'm seeing an issue with the CustomFilteringColumn used on Detail Tables when the DefaultHierarchyExpanded property is set to true. When I have filtering enabled and I expand each grid item separately, the filtering column correctly displays the drop down and the contents are rendered. However, when setting the DefaultHierarchyExpanded = true and letting the grid do its own grid item expansion, the drop down does not display for the CustomFilteringColumn except for the last set of items expanded. Even though our grid code is very customized, I've tried this set up in a couple of difference scenarios to pinpoint that it's not likely something strange that we're doing in our base code. In investigating the markup of the actual rendered grid when the drop down does not display, it appears that the <td> tag is completely empty. For convenience, I've provided our current CustomFilteringColumn code.
To reiterate; the column's drop down displays correctly for the first row, the MasterTableView items, but not for any of the grid rows underneath EXCEPT for the last item and its grid rows. Could this be a creation issue where each subsequent drop down created actually overwrites the previous instance until only the last instantiated controls remain?
| public class CustomFilteringColumn : GridBoundColumn |
| { |
| private RadComboBox list = new RadComboBox(); |
| #region Properties |
| public object ListDataSource |
| { |
| get { return list.DataSource; } |
| set |
| { |
| list.DataSource = value; |
| string selectedValue = list.SelectedValue; |
| list.DataTextField = DataKeyField; |
| list.DataValueField = DataValueField; |
| list.DataBind(); |
| list.SelectedValue = selectedValue; |
| int height = 17 * list.Items.Count; |
| if (height < 400) |
| { |
| list.Height = Unit.Pixel(height); |
| } |
| else |
| { |
| list.Height = Unit.Pixel(400); |
| } |
| } |
| } |
| public string DataKeyField |
| { |
| get |
| { |
| String s = (String)ViewState["DataKeyField"]; |
| return ((s == null) ? String.Empty : s); |
| } |
| set |
| { |
| ViewState["DataKeyField"] = value; |
| } |
| } |
| public string DataValueField |
| { |
| get |
| { |
| String s = (String)ViewState["DataValueField"]; |
| return ((s == null) ? String.Empty : s); |
| } |
| set |
| { |
| ViewState["DataValueField"] = value; |
| } |
| } |
| #endregion |
| //RadGrid calls this method when it initializes the controls inside the filtering item cells |
| protected override void SetupFilterControls(TableCell cell) |
| { |
| base.SetupFilterControls(cell); |
| cell.Controls.RemoveAt(0); |
| list.ID = "list" + this.DataField; |
| list.Skin = "Vista"; |
| list.Width = this.FilterControlWidth; |
| list.Height = Unit.Pixel(50); |
| list.NoWrap = true; |
| list.AutoPostBack = true; |
| list.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(list_SelectedIndexChanged); |
| cell.Controls.AddAt(0, list); |
| cell.Controls.RemoveAt(1); |
| } |
| public void CreateDataSource(DataTable table) |
| { |
| DataTable dt = new DataTable(); |
| dt.Columns.Add(this.DataKeyField); |
| if (!dt.Columns.Contains(this.DataValueField)) |
| { |
| dt.Columns.Add(this.DataValueField); |
| } |
| //add and empty row to the datatable as the default item in the drop-down... |
| DataRow dtRow = dt.NewRow(); |
| dtRow[DataKeyField] = ""; |
| dtRow[DataValueField] = ""; |
| dt.Rows.Add(dtRow); |
| Dictionary<string, object> values = new Dictionary<string,object>(StringComparer.InvariantCultureIgnoreCase); |
| foreach (DataRow row in table.Rows) |
| { |
| if (!values.ContainsKey(row[DataKeyField].ToString())) |
| { |
| dtRow = dt.NewRow(); |
| dtRow[DataKeyField] = row[DataKeyField]; |
| dtRow[DataValueField] = row[DataValueField]; |
| values.Add(row[DataKeyField].ToString(), row[DataValueField]); |
| dt.Rows.Add(dtRow); |
| } |
| } |
| this.ListDataSource = dt; |
| } |
| void list_SelectedIndexChanged(object sender, EventArgs e) |
| { |
| GridFilteringItem filterItem = (sender as RadComboBox).NamingContainer as GridFilteringItem; |
| if (this.DataType == System.Type.GetType("System.Int32") || |
| this.DataType == System.Type.GetType("System.Int16") || |
| this.DataType == System.Type.GetType("System.Int64")) |
| { |
| filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName)); |
| } |
| else // treat everything else like a string |
| filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName)); |
| } |
| //RadGrid calls this method when the value should be set to the filtering input control(s) |
| protected override void SetCurrentFilterValueToControl(TableCell cell) |
| { |
| base.SetCurrentFilterValueToControl(cell); |
| RadComboBox list = (RadComboBox)cell.Controls[0]; |
| list.SelectedValue = this.CurrentFilterValue; |
| } |
| //RadGrid calls this method to extract the filtering value from the filtering input control(s) |
| protected override string GetCurrentFilterValueFromControl(TableCell cell) |
| { |
| RadComboBox list = (RadComboBox)cell.Controls[0]; |
| return list.SelectedValue; |
| } |
| protected override string GetFilterDataField() |
| { |
| return this.DataField; |
| } |
| public override GridColumn Clone() |
| { |
| CustomFilteringColumn res = new CustomFilteringColumn(); |
| res.CopyBaseProperties(this); |
| return this; |
| } |
| } |