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

Filtering for a null

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kencox
Top achievements
Rank 1
kencox asked on 20 May 2010, 07:00 PM
I'm using a radcombox for a custom filter on a column where  DataType="System.Int32". However, some rows are actually null.

How do I check for a possible null in the filter routine?

I've tried     tableView.filter("BoMID", null, "EqualTo");  without success.

Here's some non-working code:

   <telerik:GridTemplateColumn HeaderText="BoM" UniqueName="BoMID" FilterControlWidth="30px" 
                        AllowFiltering="true" DataType="System.Int32" DataField="BoMID" ReadOnly="True">  
                        <ItemTemplate> 
                            <asp:Literal ID="litBoM" runat="server" Text='<%#FormatBoMColumn(Eval("BoMID"))%>'></asp:Literal> 
                        </ItemTemplate> 
                        <FilterTemplate> 
                            <telerik:RadComboBox ID="ImportedFilter" runat="server"   
                                 AllowCustomText="false" DropDownWidth="70px" Width="15px">  
                                <Items> 
                                    <telerik:RadComboBoxItem Text="No Filter" Value="" /> 
                                    <telerik:RadComboBoxItem Text="Yes" Value="1" /> 
                                    <telerik:RadComboBoxItem Text="No" Value="0" /> 
                                </Items> 
                            </telerik:RadComboBox> 
                            <telerik:RadScriptBlock ID="RadScriptBlock12" runat="server">  
                                <script type="text/javascript">  
                                    function RethrownSelectedIndexChanged(sender, args) {  
                                                    var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");  
                                        var filterVal = args.get_item().get_value();  
 
                                        if (filterVal == null) {  
                                            tableView.filter("BoMID", filterVal, "NoFilter");  
                                        }  
                                        else if (filterVal == 1) {  
                                            tableView.filter("BoMID", 0, "GreaterThan");  
 
                                        }  
                                        else if (filterVal == 0) {  
                                            tableView.filter("BoMID", null, "EqualTo");  
                                        }  
                                    }     
                                </script> 
                            </telerik:RadScriptBlock> 
                        </FilterTemplate> 
                        <HeaderStyle Width="40px" Wrap="False" HorizontalAlign="Center" /> 
                        <ItemStyle Width="40px" Wrap="False" HorizontalAlign="Center" /> 
                    </telerik:GridTemplateColumn> 

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 26 May 2010, 09:10 AM
Hello Ken,

To achieve the desired functionality you could try using the following code snippet:
tableView.filter("BoMID",null,Telerik.Web.UI.GridFilterFunction.IsNull);

Also you need to set RadGrid.EnableLinqExpressions property to false.
Additionally I am sending you a simple example which demonstrates the desired functionality.

I hope this helps.  

Kind regards,
Radoslav
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
kencox
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or