Custom Filter - RadDatePicker to Handle DBNULL Values

3 posts, 0 answers
  1. Deva Kumar
    Deva Kumar avatar
    12 posts
    Member since:
    Nov 2009

    Posted 19 Nov 2009 Link to this post

    Dear Experts,

    I have a issue with performing custom filtering using RadDatePicker on RadGrid.

    I have a datetime column on the grid and I am using template column to assign the values on the grid.

    The RadDatePicker control works perfect on one date column which contains DateTimeValues values on all the rows.

    But it is not working on a column where there are very few values and also contains DBNULL values. Thanks in advance.

    Here is the code
    -------------------------------------

    <FilterTemplate>
                                                <telerik:RadDatePicker ID="PickupDatePicker" runat="server" Width="90px" ClientEvents-OnDateSelected="PickupDateSelected"
                                                    DbSelectedDate='<%# SetPickupDate(Container) %>' />
                                                <telerik:RadScriptBlock ID="RadScriptPickupDate" runat="server">

                                                    <script type="text/javascript">
                                                        function PickupDateSelected(sender, args) {
                                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            var date = FormatPickupSelectedDate(sender);                                                       
                                                            tableView.filter("Pickup_Dt", date, "EqualTo");
                                                        }
                                                        function FormatPickupSelectedDate(picker) {
                                                            var date = picker.get_selectedDate();
                                                            var dateInput = picker.get_dateInput();
                                                            var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
                                                            return formattedDate;
                                                        }
                                                    </script>

                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
    -------------------------------------
    protected DateTime? SetPickupDate(Telerik.Web.UI.GridItem item)
        {
            if (item.OwnerTableView.GetColumn("Pickup_Dt").CurrentFilterValue == string.Empty)
            {
                return new DateTime?();
            }
            else
            {
                return DateTime.Parse(item.OwnerTableView.GetColumn("Pickup_Dt").CurrentFilterValue);
            }
        }   

     protected void uxRGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridFilteringItem)
                {
                 Telerik.Web.UI.RadDatePicker dtpickerPickupDate = (Telerik.Web.UI.RadDatePicker)(e.Item as Telerik.Web.UI.GridFilteringItem)["Pickup_Dt"].Controls[1];
                    dtpickerPickupDate.Culture = Thread.CurrentThread.CurrentUICulture; 
                }
    }
    -------------------------------------

  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 24 Nov 2009 Link to this post

    Hi Deva,

    Can you check whether you use the .NET 3.5 build of RadControls (2009.3.1103.35) in your projec and set EnableLinqExpressions = false through your RadGrid's tag? If not, try it out to see whether this helps.
     
    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Deva Kumar
    Deva Kumar avatar
    12 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Thanks a lot for your kind help Sebastian.

    Sorry, I am not using the latest version which you have provided. (Mine is 2009.2.826.35). I should request my client manager to get the update.

    I have tried and implemented the other way - which I shouldn't have done. I assigned DateTime.MinValue to all the DateTime columns which was having DBNULL values. By this I was able to surpass the problem temporarily. And while displaying on the screen, I will avoid displaying the DateTime.MinValue.

    Thank you Sebastian. I will get the latest update and try with your solution.

    Thank you,
    Deva
Back to Top