This is a migrated thread and some comments may be shown as answers.

Filtering not working with custom template column

5 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anup Kagalkar
Top achievements
Rank 1
Anup Kagalkar asked on 19 Aug 2010, 08:09 AM
Hi

I have created custom template column for filtering . Given below is code of MyCustomFilteringTemplateColumn.cs. I m using Entity datasource 


 //RadGrid will cal this method when the value should be set to the filtering input control(s)
        protected override void SetCurrentFilterValueToControl(TableCell cell)
        {
            base.SetCurrentFilterValueToControl(cell);
            RadComboBox combo = (RadComboBox)cell.Controls[0];
            if ((this.CurrentFilterValue != string.Empty))
            {
                combo.Text = this.CurrentFilterValue;
            }
        }

     

        //RadGrid will cal this method when the filtering value should be extracted from the filtering input control(s)
        protected override string GetCurrentFilterValueFromControl(TableCell cell)
        {
            RadComboBox combo = (RadComboBox)cell.Controls[0];
         
            this.CurrentFilterFunction = (combo.Text.Trim() != "") ? GridKnownFunction.EqualTo : GridKnownFunction.NoFilter;
            return combo.Text;

           
        }

        private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            
             
                    Collection<Entities.ProjectUsersAndGroups> collDataSource = (Collection<Entities.ProjectUsersAndGroups>)FilterDataSource;
                    ((RadComboBox)o).DataTextField = this.DataField;
                    ((RadComboBox)o).DataValueField = this.DataField;
                    ((RadComboBox)o).DataSource = collDataSource;
                    ((RadComboBox)o).DataBind();
                    break;

           

        }

        private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer;
            if ((this.UniqueName == "Index"))
            {
                //this is filtering for integer column type 
                filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.DataField));
            }
            //filtering for string column type
            if (this.UniqueName == "ProjectCategoryName")
                this.UniqueName = "ProjectCategoryDetails.ProjectCategoryName";

            filterItem.FireCommandEvent("Filter", new Pair("Contains", this.DataField));


        }



While filtering I am getting error  "Expression expected " on this line   filterItem.FireCommandEvent("Filter", new Pair("Contains", this.DataField));".


Please help me out 

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 19 Aug 2010, 02:16 PM
Hello Anup,

Try to set RadGrid EnableLinqExpressions property to false and let me know if it helps to eliminate the error message.

Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Anup Kagalkar
Top achievements
Rank 1
answered on 19 Aug 2010, 04:10 PM
Error message is not coming but filtering is not happening
0
Pavlina
Telerik team
answered on 24 Aug 2010, 02:39 PM
Hello Anup,

Could you please confirm that you have not override DataField property in your custom column?

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Huy
Top achievements
Rank 1
answered on 26 Apr 2012, 07:37 AM
It works, Thanks so much.
0
Won
Top achievements
Rank 1
answered on 01 Nov 2012, 04:38 AM
This works even as of Oct, 2012. I'm using .net 4.

The document for this filtering should be updated accordingly.

http://www.telerik.com/help/aspnet-ajax/grid-google-like-filtering.html
Tags
Grid
Asked by
Anup Kagalkar
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Anup Kagalkar
Top achievements
Rank 1
Huy
Top achievements
Rank 1
Won
Top achievements
Rank 1
Share this question
or