We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridFilterBar: dropdown contens is not drawn when opened

Thread ID:

Created:

Updated:

Platform:

Replies:

34385 Sep 8,2005 12:51 PM UTC Sep 13,2005 02:16 PM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 8, 2005 12:51 PM UTC

I have derived GridFilterBar and overridden WireGrid and GetFilterFromRow (as described in http://64.78.18.34/Support/Forums/message.aspx?MessageID=8368). It seems to work except that contens of the filterbar dropdown is not shown. For instance in a filter dropdown the following items should be shown when selected: "(none)" "(custom)" "Foo" "Bar" But it is shown as: "" "" "" "" when I select item 3 it will write "Foo" in the dropdown and perform the correct filtering. Why is the contens of the filter-dropdown not drawn?

Administrator [Syncfusion]
Replied On September 8, 2005 02:17 PM UTC

Hi, Please double check your code in the GridFilterBar.CreateEntries() override. Here is one more sample that handles this issue. http://www.syncfusion.com/Support/user/uploads/ForumFilterBarDisplayMember_deee6d37.zip If this doesn''t help, can you upload a sample showing the problem? Best regards, Jay N

Administrator [Syncfusion]
Replied On September 8, 2005 02:51 PM UTC

Here is my code: using System; using System.Data; using Syncfusion.Windows.Forms.Grid; namespace XXX.CommonGui { /// /// Summary description for Class1. /// public class XXXGridFilterBar : GridFilterBar { public override void WireGrid(GridDataBoundGrid grid, GridStyleInfo style) { base.WireGrid (grid, style); if(grid != null) { DataTable dt = GetDataTable(); if(dt != null) { GridBoundColumnsCollection gbcc; gbcc = (grid.GridBoundColumns.Count == 0) ? grid.Binder.InternalColumns : grid.GridBoundColumns; int row = GetFilterRow(); for(int gbcIndex = 0; gbcIndex < gbcc.Count ; ++gbcIndex) { string colName = gbcc[gbcIndex].MappingName; GridStyleInfo style1 = gbcc[gbcIndex].StyleInfo; if(style1.CellType == "ComboBox" && style1.DataSource is DataTable && style1.DisplayMember != style1.ValueMember) { int col = grid.Binder.NameToColIndex(colName); DataView dv = new DataView(style1.DataSource as DataTable, "", style1.DisplayMember, DataViewRowState.CurrentRows); grid[row, col].DataSource = CreateComboUniqueEntries(dv, style1.DisplayMember, style1.ValueMember); grid[row, col].DisplayMember = style1.DisplayMember; grid[row, col].ValueMember = style1.ValueMember; } } } grid.Refresh(); } } protected override string GetFilterFromRow(GridDataBoundGrid grid) { GridCurrentCell cc = grid.CurrentCell; int col = cc.ColIndex; int row = this.GetFilterRow(); cc.ConfirmChanges(); string s = grid[row, col].Text; if(s.IndexOf("custom") > -1) return base.GetFilterFromRow(grid); DataTable dt = this.GetDataTable(); string colName; string rowFilter = ""; if(cc.IsActive) cc.Deactivate(false); if(GridUtil.IsEmpty(s) || s == "(none)") { grid[row, col].Text = ""; grid[row, col].Tag = ""; } else { string gridColName = grid.Binder.InternalColumns[grid.Binder.ColIndexToField(col)].MappingName; colName = dt.Columns[gridColName].ColumnName; grid[row, col].Text = s; if (s.IndexOf("''") != -1) s = s.Replace("''", "''''"); grid[row, col].Tag = string.Format("[{0}] = ''{1}''", colName, s); } //otherwise form the filter string from the filter row values for(int j = 1; j <= grid.Model.ColCount; ++j) { s = grid[row, j].Tag as string; if(s != null && s.Length > 0) { if(rowFilter.Length > 0) rowFilter += " and "; rowFilter += (string) s; } } return rowFilter; } private DataTable CreateComboUniqueEntries(DataView dv, string displayMember, string valueMember) { DataTable dt = new DataTable(displayMember); dt.Columns.Add(new DataColumn(displayMember)); dt.Columns.Add(new DataColumn(valueMember)); DataRow dr = dt.NewRow(); dr[0] = "(none)"; dr[1] = "(none)"; dt.Rows.Add(dr); string s = ""; for(int i = 0; i < dv.Count; ++i) { if(s != dv[i].Row[displayMember].ToString()) { s = dv[i].Row[displayMember].ToString(); dr = dt.NewRow(); dr[0] = s; dr[1] = dv[i].Row[valueMember].ToString(); dt.Rows.Add(dr); } } return dt; } } } -------- and it is called like this: this.rightLineGrid.BeginUpdate(); if (this.filterBar != null && this.filterBar.Wired) this.filterBar.UnwireGrid(); /* Some code */ this.filterBar.WireGrid(this.gridDataBoundGrid); this.rightLineGrid.EndUpdate();

Administrator [Syncfusion]
Replied On September 8, 2005 06:46 PM UTC

I copied your code into the original project, just swapping out the derived filterbar class, and the droplist was not empty in that modified sample for me. If you place stops in your CreateComboUniqueEntries method, and step through teh code, are the values as expected? If you can upload a sample project, we can try to debug it here.

Administrator [Syncfusion]
Replied On September 13, 2005 08:42 AM UTC

Here''s a demo project that has the problem. CS_3070.zip

Administrator [Syncfusion]
Replied On September 13, 2005 12:48 PM UTC

Hi, I couldn''t run your sample, RightLine.xsd was missing in the sample. Can you please try the following to see if that helps? In your GridFilterBar.WireGrid() override, clear the cell''s datasource, displaymember and value member before assiging the new one. public class MyGridFilterBar : GridFilterBar { public override void WireGrid(GridDataBoundGrid grid, GridStyleInfo style) { // // // if(style1.CellType == "ComboBox" && style1.DataSource is DataTable && style1.DisplayMember != style1.ValueMember) { int col = grid.Binder.NameToColIndex(colName); DataView dv = new DataView(style1.DataSource as DataTable, "", style1.DisplayMember, DataViewRowState.CurrentRows); ///***Added.... grid[row, col].DataSource = null; grid[row, col].DisplayMember = null; grid[row, col].ValueMember = null; grid[row, col].DataSource = CreateComboUniqueEntries(dv, style1.DisplayMember, style1.ValueMember); grid[row, col].DisplayMember = style1.DisplayMember; grid[row, col].ValueMember = style1.ValueMember; } } } Thanks, Jay N

Administrator [Syncfusion]
Replied On September 13, 2005 02:16 PM UTC

That solves the problem :-) Thanks a lot Syncfusion. mup

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;