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

Custom option for filtering

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kati
Top achievements
Rank 1
Kati asked on 17 Mar 2010, 12:37 PM
Hi

is it possible to do the following?

I have a radgrid where one of the columns has the this values:  Not Stared, In Progress, Complete, Ongoing

like this


No          Status

1          Not Started
2          In Progress
3          Ongoing
4          In Progress
5          In Progress
6          Complete


I have a custom filter on the status column (a dropdown with 4 items) so I can filter on the 4 different types.
The Customer now wants a 5th item in the filter dropdown, and this 5th should get back all the records that are not Complete.

How could I make this happen?


Thanks


Kati

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 19 Mar 2010, 07:36 AM
Hi Kati,

I guess you are using the FitlerTemplate functionality of the grid as explained in the following blog post:
http://blogs.telerik.com/vladimirenchev/posts/08-12-03/new_feature_asp_net_ajax_grid_filter_template.aspx

You can easily achieve your requirement as follows: in the SelectedIntexChanged client method inspect what's the combo box selected value (args.get_item().get_value()). If it is "Not complete", throw the following filter command:

<script type="text/javascript">
  
  function SelectedIndexChanged(sender args)
  {
    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    
    if (agrs_get_item().get_value() == "Not complete")
    {
    tableView.filter("Status", "Complte", "NotEqualTo");
    }   
    else
    {
    tableVeiw.filter("Status", args.get_item().get_value(), "EqualTo");
    }
  
  }
</script>

I hope this helps.

All the best,
Tsvetoslav
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
Kati
Top achievements
Rank 1
answered on 19 Mar 2010, 11:45 AM
Hi

No, I am not using Filtertemplate. I am using RadGridCustomTemplateColumn.


if(e.CommandName == RadGrid.FilterCommandName)
            {
                Pair filterPair = (Pair)e.CommandArgument;
                if(filterPair.Second as string == "Status")
                {
                    string colName = filterPair.Second.ToString();
                    string filterText = ((e.Item as GridFilteringItem)["Status"].Controls[0] as RadComboBox).SelectedValue;
                    
                    
                    if(filterText == "Outstanding")
                    {
                        e.Canceled = true;
                        string newFilter = "(([" + filterPair.Second + "] ='" + "Not Started" + "') OR ([" + filterPair.Second + "] ='" + "In Progress" + "' OR ([" + filterPair.Second + "] ='" + "Ongoing" + "'))";                    
                          
                            grdActions.Rebind();     
                
                    }
                }


In the RadGridCustomTemplateColumn.cs    class the following function is never being called, so the filtering does not happen sadly:

protected override string GetCurrentFilterValueFromControl(TableCell cell)
        {
            RadComboBox cboStatusFilter = (RadComboBox)cell.Controls[ 0 ];
            return cboStatusFilter.SelectedValue;
        } "          
0
Tsvetoslav
Telerik team
answered on 23 Mar 2010, 02:18 PM
Hello Kati,

Have you closely followed the directions provided in the following help article (here) on how to achieve your scenario. If so, I'd ask you to open up a formal support ticket and send your files since based on the information provided, it is very diffcult to say what the issue might be.

Thanks in advance.

Regards,
Tsvetoslav
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.
Tags
Grid
Asked by
Kati
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Kati
Top achievements
Rank 1
Share this question
or