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. Image for the cookie policy date

GridGroupingControl filter bar

Hello!

If I use the text box as filter bar, after the input the filter bar simply clears its contents. It works just fine, but I would like for user to see the filter criteria.
For example if he types in the letter "o",
all of the cells that begin with letter "o" are displayed, but there is nothing written in the filter bar anymore. How can I make it save the user input?

Thanks in advance.

8 Replies

HA haneefm Syncfusion Team March 30, 2007 02:46 PM UTC

Hi Vicko,

One way you can do this by handling the QueryCellInfo event to set the CellType to "TextBox" in a filterbar cell and also you can handle the TableControlCurrentCellKeyPress event for adding the RecordFilters in a grid.

Here is a sample
ExampleGrid0.zip

Best regards,
Haneef


VH Vicko Hazdovac April 2, 2007 09:34 AM UTC

Heh, it seems I haven't been myself on Friday.
I failed to explain the problem on two occasions. Here is another word document with screenshots to avoid any further misunderstandings...

TextBoxFilter.zip


HA haneefm Syncfusion Team April 2, 2007 11:59 PM UTC

Hi Vicko,

Sorry for the inconvenience. I am not able to open a TextBoxFilter.docx file in my system. Can you please send us a TextBoxFilter.doc , we will debug the issue here.

Best regards,
Haneef


VH Vicko Hazdovac April 3, 2007 06:27 AM UTC

Sorry, about that - I thought I've setup the MS Word 2007 to save to .doc by default. I was wrong obviously :).
Anyway - here's the .doc version.

TextBoxFilter0.zip


HA haneefm Syncfusion Team April 3, 2007 11:46 PM UTC

Hi Vicko,

This can be achieved by handling the TableControlDrawCell event. In that event, you need to draw the filter text explictly on textbox filter cell in a grid. The following is the code snippet.

void gridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (TextFilterText != string.Empty
&& style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.FilterBar
&& style.CellType == "TextBox")
{
e.Inner.Cancel = true;
e.Inner.Graphics.DrawString(TextFilterText, e.Inner.Style.GdipFont, new SolidBrush(e.Inner.Style.TextColor), e.Inner.Bounds);
}
}

Please refer to the attached sample for implementation.
TextFiltersample.zip

Best regards,
Haneef


VH Vicko Hazdovac April 11, 2007 02:21 PM UTC

Hmm... There's a lot of questions I need to ask you, and it turned out that some of the issues are still there.

It would take too much to write it all in one post so I've attached a file with word documents and an example of the project.

thanks in advance

Projects.zip


VH Vicko Hazdovac April 16, 2007 06:24 AM UTC

Hello....

Is there anybody out there?


HA haneefm Syncfusion Team April 16, 2007 11:21 PM UTC

Hi Vicko,

Issue 1: Filter stop working.

The reason for getting this behavior is that CurrentElement is not resetted properly. One way you can resolve this issue by handling the TableControlCurrentCellStartEdinting event of the grid and set CurrentElement to null in a GridTable. Here is a code snippet.

void gridGroupingControl1_TableControlCurrentCellStartEditing(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
if (cr != null)
{
GridTableCellStyleInfo style = cr.CurrentStyle as GridTableCellStyleInfo;

if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.FilterBar
&& style.CellType == "TextBox")
{
e.TableControl.Table.CurrentElement = null;
}
}
}

Issue 2: Filter Text problem

You can do this by using the Hashtable for each column of the Filterbar row and draw the corresponding filter string in a TableControlDrawCellDisplayText event of the grid. Please refer to the attached sample for more details and let me know if this helps.

Sample : Filter.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon