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

Is it possible to Change Filter Template combo box Selected value from Client side within RadGrid?

1 Answer 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ronak
Top achievements
Rank 1
Ronak asked on 06 Apr 2012, 01:54 PM
Hi all,

Right now, I am facing a problem with my Filter Template.
I have studied this  link http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx .
It is good example.
But my problem is that one of my column has some different condition.
The combo box has 4 value (i.e. New, In Progress, Near completion, Closed). it is filled by data source SDSStatus & two more items are added i.e. "All" & "Open Only".
Now, Suppose If I am select Open Only from combo,except "Closed" records all other records should be displayed in grid. 
Actually, I want to know that, Is it possible to filter like this way? 
Please help me its urgent.
see below code.  ( That is what I am thinking ).

<telerik:GridBoundColumn DataField="StatusName" HeaderText="Status Name" SortExpression="StatusName"
                                  UniqueName="StatusName"  >
                                  <FilterTemplate>
                          <telerik:RadComboBox ID="RadComboBoxSts" DataSourceID="SDSStatus" DataTextField="StsName"
                              DataValueField="StsName" Skin="Office2007" Width = "100%" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("StatusName").CurrentFilterValue %>'
                              runat="server" OnClientSelectedIndexChanged="StsIndexChanged">
                              <Items>
                                  <telerik:RadComboBoxItem Text="All"/>
                                               <telerik:RadComboBoxItem Text="Open Only"/> 
                              </Items>
                          </telerik:RadComboBox>
                          <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
 
 
                              <script type="text/javascript">
                                  function StsIndexChanged(sender, args) {
                                                     
                                  var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
 
                                If(args.get_item().get_text() == "Open Only")
                                                  {
                                      tableView.filter("TaskTypeName", "Closed", "NotEqualTo");
                                                   // Combo selected text must be Open Only after filtering.
                                                   }
                                   Else
                                                    {
                                      
                                      tableView.filter("TaskTypeName", args.get_item().get_value(), "EqualTo");
                                                    }  
                                  }
                              </script>
 
 
                          </telerik:RadScriptBlock>
                      </FilterTemplate>
                                  <HeaderStyle  Width = "6%" VerticalAlign ="Top"/>
                                  <ItemStyle  Width = "6%" VerticalAlign ="Top"/>
                              </telerik:GridBoundColumn>


 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 11 Apr 2012, 09:58 AM
Hello Ronak,

As long as the column is bound to a data field that contains the respective values, more specifically "Closed", it is fine to filter by them and your code seems to be correct for such case.

Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Ronak
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or