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

Filtering by dropdown and filter menu simultaneously

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nilanjan
Top achievements
Rank 1
Nilanjan asked on 29 Jan 2009, 03:20 PM
In a radgrid filtering can be done by
1. A filter text box and a filter menu next to it. This gives flexibility to search with various criteria like 'equal to' , 'contains', etc.
2. By drop down where we select a value and filter criteria is only 'equal to'.

Can we combine both of the above ? I want to select a value from drop down then open the filter menu and select a criteria like 'equal to' , 'contains', etc.
Is this possible? If so then pls provide any code snippet or link.

1 Answer, 1 is accepted

Sort by
0
alo
Top achievements
Rank 1
answered on 29 Jan 2009, 05:22 PM
I'm currently working on a similar task.  I haven't got it to fully work yet, but I'll share what I have done so far.  Are you following the MyCustomFilteringColumn example?

If so, the following line in the SetupFilterControls method is used to remove the little filter options icon:

cell.Controls.RemoveAt(1); 

I believe you could remove the above line, unwire the RadComboBoxSelectedIndexChangedEventHandler, and then you may want to limit the options in the filter criteria to those that make sense (e.g., EqualTo, NotEqualTo, NoFilter).  This can be done using Javascript as follows:

    <script type="text/javascript">  
    function FilterMenuShowing(sender, eventArgs) {  
 
        if (eventArgs.get_column().get_uniqueName() == "Rounding") {  
            var menu = eventArgs.get_menu();  
            var items = menu._itemData;  
 
            var i = 0;  
 
            while (i < items.length) {  
                if (items[i].value != "NoFilter" && items[i].value != "EqualTo" && items[i].value != "NotEqualTo") {  
                    var item = menu.findItemByValue(items[i].value);  
                    if (item != null)  
                        item._element.style.display = "none";     
                }  
                i++;  
            }  
        }  
        else {  
            var menu = eventArgs.get_menu();  
            var items = menu._itemData;  
 
            var i = 0;  
            while (i < items.length) {  
                var item = menu.findItemByValue(items[i].value);  
                if (item != null)  
                    item._element.style.display = "";     
                i++;  
            }  
        }  
    }    
 
 
   
</script> 

I hope this helps.

Al

Tags
Grid
Asked by
Nilanjan
Top achievements
Rank 1
Answers by
alo
Top achievements
Rank 1
Share this question
or