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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

FilterBar

Thread ID:

Created:

Updated:

Platform:

Replies:

25336 Feb 24,2005 04:44 PM UTC May 27,2005 08:52 PM UTC WinForms 11
loading
Tags: GridControl
Mikaël Morvan
Asked On February 24, 2005 04:44 PM UTC

Hi, Is there a way to use a filter bar with GridDataBoundGrid when the datasource is IList ? Regards, Mikaël

Administrator [Syncfusion]
Replied On February 24, 2005 05:31 PM UTC

No, it is not supported in our library. You would have to implement it yourself. The 3.0 GridGroupingControl has a filterbar that can be used with IList objects.

Mikaël Morvan
Replied On March 2, 2005 12:42 PM UTC

How do I make the filter bar use textboxes and have the display respond to each keystroke with the GridGroupingControl ? How can i use an GridFilterBar inherit class (like GridTextBoxFilterBar) with GridGroupingControl ?

Administrator [Syncfusion]
Replied On March 2, 2005 04:49 PM UTC

You will not be able to use a derived GridFilterBar class in GridGroupingControl. Try this. Handle these two events. this.groupingGrid1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(groupingGrid1_QueryCellStyleInfo); this.groupingGrid1.TableControlCurrentCellChanged += new GridTableControlEventHandler(groupingGrid1_TableControlCurrentCellChanged);
private void groupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		e.Style.ShowButtons = GridShowButtons.Hide;
		e.Style.BackColor = Color.LightGoldenrodYellow;
		e.Style.DropDownStyle = GridDropDownStyle.Editable;
		e.Style.CellType = "TextBox";
	}
}

private void groupingGrid1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		string s = string.Format("[{0}] LIKE ''{1}*''", style.TableCellIdentity.Column.MappingName, cc.Renderer.ControlText);
		this.groupingGrid1.TableDescriptor.RecordFilters.Clear();
		this.groupingGrid1.TableDescriptor.RecordFilters.Add(s);
	}
}


Mikaël Morvan
Replied On March 10, 2005 05:34 PM UTC

Thanks, I''ve copied and paste the code you send. It seems to work well, but there is a strange behaviour that appears when I try to enter a filter in one of the textbox cell (after having selected a row in the grid) the textbox control lose his focus (after I had typed the first character) and one of the result rows is selected. This prevents me to type an entire filter. Do you have an explanation or workarround ? A sample project is attached in a zip file ( WindowsApplication3_9515.zip). Here is a scenario: 1- load the application 2- type something in the "ContactName" cell filter Everything is OK Now: 3- select one the result rows 4- type something in the "ContactName" cell filter 5- a row is selected after you had typed the first character ... Regards. Mikaël.

Administrator [Syncfusion]
Replied On March 10, 2005 06:04 PM UTC

Try handling the TableControlCurrentCellMoving event.
private void gridGroupingControl1_TableControlCurrentCellMoving(object sender, GridTableControlCurrentCellMovingEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.MoveToRowIndex, cc.MoveToColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		this.gridGroupingControl1.Table.CurrentRecord = null;
	}
}

Mikaël Morvan
Replied On May 26, 2005 10:51 AM UTC

This work fine until i install the 3.2.1.0 version. Do you have any ideas ? Thanks, Mikaël >Try handling the TableControlCurrentCellMoving event. >
>private void gridGroupingControl1_TableControlCurrentCellMoving(object sender, GridTableControlCurrentCellMovingEventArgs e)
>{
>	GridCurrentCell cc = e.TableControl.CurrentCell;
>	GridTableCellStyleInfo style = e.TableControl.Model[cc.MoveToRowIndex, cc.MoveToColIndex] as GridTableCellStyleInfo;
>	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
>	{
>		this.gridGroupingControl1.Table.CurrentRecord = null;
>	}
>}
>

Administrator [Syncfusion]
Replied On May 26, 2005 01:39 PM UTC

Try switching the order of these two lines in gridGroupingControl1_TableControlCurrentCellChanged. string s1 = cc.Renderer.ControlText; this.gridGroupingControl1.TableDescriptor.RecordFilters.Clear(); //this.gridGroupingControl1.TableDescriptor.RecordFilters.Clear(); //string s1 = cc.Renderer.ControlText;

Mikaël Morvan
Replied On May 27, 2005 03:16 PM UTC

Hi, The problem is that I can''t type more than one character in the textbox filter. The filter is immediatly applied and the filter cell lose his focus. So, I have to re-select the filter cell in order to go on typing my criteria. How can i prevent this behavior ? Regards. Mikaël

Administrator [Syncfusion]
Replied On May 27, 2005 04:02 PM UTC

Try this handler.
private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		string s1 = cc.Renderer.ControlText;
		if ((s1 != null) && (s1 != string.Empty)) 
		{
			string s = string.Format("[{0}] LIKE ''{1}*''", style.TableCellIdentity.Column.MappingName, s1);
			cc.Lock();
			if(this.gridGroupingControl1.TableDescriptor.RecordFilters.Count == 0)
				this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(s);
			else
				this.gridGroupingControl1.TableDescriptor.RecordFilters[0].Expression = s;
			cc.Unlock();
		}
	}
}

Brian Wright
Replied On May 27, 2005 06:52 PM UTC

Hi.. I hate to jump into this thread. But as luck would have it, I need to do exactly what you have described. Following your instructions, everything is working like a charm, except for one thing: When a filterbar TextBox loses focus, it no longer shows the filter they typed in. For example, if I type a ''br'' in a filterbar Textbox under a specific column, it filters great.. But as soon as I leave that cell in the filterbar, the ''br'' text disappears. The filter remains, just the text disappears, making it hard for the user to remember if he even has any filters active on the grid or not. Is there a way to prevent this? >Try this handler. >
>private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
>{
>	GridCurrentCell cc = e.TableControl.CurrentCell;
>	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
>	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
>	{
>		string s1 = cc.Renderer.ControlText;
>		if ((s1 != null) && (s1 != string.Empty)) 
>		{
>			string s = string.Format("[{0}] LIKE ''{1}*''", style.TableCellIdentity.Column.MappingName, s1);
>			cc.Lock();
>			if(this.gridGroupingControl1.TableDescriptor.RecordFilters.Count == 0)
>				this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(s);
>			else
>				this.gridGroupingControl1.TableDescriptor.RecordFilters[0].Expression = s;
>			cc.Unlock();
>		}
>	}
>}
>

Administrator [Syncfusion]
Replied On May 27, 2005 08:52 PM UTC

Add a Hashtable to hold these values, an dthen modify the two even handlers to save the values in teh hashtable and retrieve them from the hashtable.
private Hashtable saveValues = new Hashtable();

private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		e.Style.ShowButtons = GridShowButtons.Hide;
		e.Style.BackColor = Color.LightGoldenrodYellow;
		e.Style.DropDownStyle = GridDropDownStyle.Editable;
		e.Style.CellType = "TextBox";
		e.Style.CellValue = saveValues[e.Style.TableCellIdentity.Column];
	}
}


private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
	{
		string s1 = cc.Renderer.ControlText;
		if ((s1 != null) && (s1 != string.Empty)) 
		{
			string s = string.Format("[{0}] LIKE ''{1}*''", style.TableCellIdentity.Column.MappingName, s1);
			cc.Lock();
			if(this.gridGroupingControl1.TableDescriptor.RecordFilters.Count == 0)
				this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(s);
			else
				this.gridGroupingControl1.TableDescriptor.RecordFilters[0].Expression = s;
			if(saveValues.ContainsKey(style.TableCellIdentity.Column))
				saveValues[style.TableCellIdentity.Column] = s1;
			else
				saveValues.Add(style.TableCellIdentity.Column,s1);

			cc.Unlock();
		}
	}
}

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

;