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

Custom filter control (textbox + button)

3 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 18 Aug 2011, 11:42 AM
Hello,

I try to implement custom filter control like here. I put a textbox and button into template column and everything now shows fine in filter row. But I need to set custom button which will contain fully custom filter menu. I want it to display when I press the button and send a filter command  when menu item is selected. But right now I can't event start built-in filter menu. I tried to add button onclick event like on your demo page, i.e.
$find("RadGrid1")._showFilterMenu("RadGrid1_ctl00", "ContactName", event); return false; __doPostBack('RadGrid1$ctl00$ctl02$ctl02$Filter_ContactName','')
but I always get a JS error  here:
this._buildFilterMenuItemList(this._filterMenu,f._data.FilterListOptions,f._data.DataTypeName,f._data.CurrentFilterFunction,f);
If I translate it to English, it's going to be like "Cannot get a value for _data; it's not defined or has a null value". Something like this.
So I have 2 questions:
  a. Is this possible to display built-in filter menu when clicking on custom button inside a filter template?
  b. Is this possible to built a fully custom menu and make it work the same way as built-in?
Thank you.

3 Answers, 1 is accepted

Sort by
0
Dmitry
Top achievements
Rank 1
answered on 19 Aug 2011, 09:21 AM
Hello,
I have to clarify what I need this for. I need to put a custom conrtol in filter template. Control contains 3 elements - a dropdown menu, textbox and button. From dropdown menu I will select filter options (Equals, IsNull and so on) and the button must run filter command. Instead of textbox there might be some other controls like combobox and such. And of course, filter commands list will be different for each column type.
So the use case of all these is like
  1. User selects filter option from dropdown menu
  2. User enters data into textbox or whatever control I put into template
  3. User hits the button or presses Enter, not much difference
  4. And... profit!

I think, the button or textbox keypress client event must initiate a postback with certain arguments or preferrably send a filter command to the server. How do I do all above?
Thank you.
0
Iana Tsolova
Telerik team
answered on 23 Aug 2011, 08:40 AM
Hi Dmitry,

I would suggest that you do not use the built-in grid filtering menu but build your own. For that purpose you can add a new context menu and set the filter button as its target control. Then handle the menu OnClientClick client-side event, and there based on the selected values, call the fireCommand() method of the GridTableView.

Best wishes,
Iana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dmitry
Top achievements
Rank 1
answered on 24 Aug 2011, 09:30 AM
Thank you for reply.
I did that and now it looks like this is going to work if there weren't some problem with it. I described it here
Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Dmitry
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or