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

Add text in the cell of Grid Dynamic Filter Bar

Dear Support:

Good day. as I writing a code to add grid grouping control and add dynamic filter in this grid
I would like to the assign the string value in the particular column in Grid Dynamic Filter Bar and also preset the logic function is "Match" during load the grid
For example

gridgroupcontrol1.filterbar.columns[1].text = "peter"
gridgroupcontrol1.filterbar.columns[1].logic = Match


Can I do that ?

Thanks 

Michael

10 Replies

MA Mahendran Annamalai Syncfusion Team August 17, 2015 03:44 PM UTC

Hi Michael,

Thanks for using Syncfusion products.

Setting Filtering for particular column in form loading can achieved by adding modified filtering condition to the particular column as per below code snippet. Changing text in FilterBar  can be done by using gridGroupingControl1.TableControlDrawCellDisplayText .



FilterCondition condition = new FilterCondition(FilterCompareOperator.Like, "Sample data1");

// Add the Condition to the particular Column.

RecordFilterDescriptor rf = new RecordFilterDescriptor("Sample Test", condition);

// Add the RecordFilterDescriptor to the RecordFilters.

this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(rf);


// changing FilaterBar Display Text.

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)

{

    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);

    if (e.Inner.ColIndex == 1)

    {

        if ( style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)

        {

            e.Inner.DisplayText = "Sample data1";

        }

    }

}



Sample:   GridGroupingControl_Demo_CS


Please let me know of you have any concerns.



Thanks,

Mahendran.A



MK Michael K August 18, 2015 08:12 AM UTC

Dear Mahendran 


Thanks for your help, will try to do it 

:)


MK Michael K August 18, 2015 09:15 AM UTC

Dear Mahendran  :

One more question , how to focus the filter bar on the form load. That mean, when the windows form open, user can type the text on filter bar without using the mouse to click filter bar instead

Thanks for your help

Michael


AK Adhikesevan Kothandaraman Syncfusion Team August 19, 2015 09:29 AM UTC

Hi Michael,

Thank you for your update.

Query
how to focus the filter bar on the form load. That mean, when the windows form open, user can type the text on filter bar without using the mouse to click filter bar instead
Suggestion 1:
If you want to set the focus to the filter bar cell on Form_Load, you can move the current cell to the specific row, col index. Please refer the below code snippet,

Code snippet:

//Activate the Filterbar cell on form load (RowIndex,ColIndex)
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(3, 1, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus);

Suggestion 2:
If you want to type the text on FilterBar Cell without using mouse click, It can be achieved by using the CurrentCell.Activate() method in DrawCellDisplayText event. Please refer the following code snippet,

Code Snippet:

//Activate the CurrentCell on the Filterbar cell using (RowIndex,ColIndex)
this.gridGroupingControl1.TableControl.CurrentCell.Activate(e.Inner.RowIndex, e.Inner.ColIndex);


Sample:
http://www.syncfusion.com/downloads/support/forum/119921/ze/FilterBarFocus-1198430216

Please let me know if you have any other concern.

Regards,
Adhi.


MK Michael K August 19, 2015 03:15 PM UTC

Dear Adhi:

Thanks for your information, I try to run your sample and find the one problem and don't know how to fix

The problem is that, when I run your sample code, it form load, the cursor locate in the first column of filter bar
There have some record "Sample Data xxx" in column 1, when I type "Sample" in the filter bar , it only show only one character on 1st column of filter bar
If you use mouse to click clear , it return to normal


any idea :) 

Thanks


AK Adhikesevan Kothandaraman Syncfusion Team August 20, 2015 12:43 PM UTC

Hi Michael,

 

Regret for the inconvenience.

 

Please use the second suggestion of my previous update. It will focus the filter bar cell properly and you can have access to type the text in the cell continuously.

 

Code Snippet:

//Activate the CurrentCell on the Filterbar cell using (RowIndex,ColIndex)
this.gridGroupingControl1.TableControl.CurrentCell.Activate(RowIndex,ColIndex);

 

Sample:

http://www.syncfusion.com/downloads/support/forum/119921/ze/FilterBar1068739918

 

Please let me know if you have any  other concern.

 

Regards,

Adhi.



MK Michael K August 21, 2015 02:28 AM UTC

Dear Mahendran :

Thanks for your example, and this sample is what I need

Thanks very much :)




RP Ranjani Prabhakaran Syncfusion Team August 21, 2015 05:53 AM UTC

Hi Michael,
Thanks for the update.
Please let us know if you need any further assistance.
Regards,
 Ranjani


RA rajat replied to Michael K April 4, 2018 12:22 PM UTC

Dear Mahendran  :

One more question , how to focus the filter bar on the form load. That mean, when the windows form open, user can type the text on filter bar without using the mouse to click filter bar instead

Thanks for your help

Michael

thanks for book


SN Sindhu Nagarajan Syncfusion Team April 5, 2018 04:30 AM UTC

Hi Rajat, 

Thanks for the update. 

Please let us know if you need any further assistance on this. 

Regards, 
Sindhu

Loader.
Live Chat Icon For mobile
Up arrow icon