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

Rad grid filter problem

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tal
Top achievements
Rank 1
Tal asked on 06 Oct 2013, 12:05 PM
Hello,
I am having a rad grid, in which I try to filter one column according to a range of dates.
I don't know what is the problem, but the filter is doing its job only by the day of the month.
I will appreciate if you have a look on the following.

Thank you in advance.
Tal

  ********** aspx:***************
 
<telerik:GridBoundColumn DataField="date" HeaderText="תאריך" DataType="System.DateTime"
                                   SortExpression="date" UniqueName="Date"
                   DataFormatString="{0:D}"  HeaderStyle-Width="330px"  ItemStyle-HorizontalAlign="Center">
                   <FilterTemplate>
                       מתאריך
                       <telerik:RadDatePicker ID="FromDate"  Culture="he-IL" runat="server" Width="140px" ClientEvents-OnDateSelected="FromDateSelected"
                           MinDate="07-04-1000" MaxDate="05-06-3000" DbSelectedDate='<%# startDate %>'/>
                           <dateinput DateFormat="dd/MM/yyyy"></DateInput
                      עד תאריך
                       <telerik:RadDatePicker  ID="ToDate" Culture="he-IL" runat="server" Width="140px" ClientEvents-OnDateSelected="ToDateSelected"
                           MinDate="07-04-1000" MaxDate="05-06-3000" DbSelectedDate='<%# endDate %>'/>
                           <dateinput DateFormat="dd/MM/yyyy"></DateInput>
 
                       <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                        
                           <script type="text/javascript">
                               function FromDateSelected(sender, args) {
                                   var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                   var ToPicker = $find('<%# ((GridItem)Container).FindControl("ToDate").ClientID %>');
 
                                   var fromDate = FormatSelectedDate(sender);
                                   var toDate = FormatSelectedDate(ToPicker);
                                   if (toDate != '') {
                                       tableView.filter("Date", fromDate + " " + toDate, "Between");
                                   }
 
                               }
                               function ToDateSelected(sender, args) {
                                   var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                   var FromPicker = $find('<%# ((GridItem)Container).FindControl("FromDate").ClientID %>');
 
                                   var fromDate = FormatSelectedDate(FromPicker);
                                   var toDate = FormatSelectedDate(sender);
                               
                                      
                                       if (fromDate != '')
                                       {
                                       tableView.filter("Date", fromDate + " " + toDate, "Between");
                                   }
                               }
                               function FormatSelectedDate(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>
               </telerik:GridBoundColumn>



code behind cs:
 
     if (e.CommandName == RadGrid.FilterCommandName)
            {
                Pair filterPair = (Pair)e.CommandArgument;
  
                switch (filterPair.Second.ToString())
                {
                    case "date":
                        this.startDate = ((e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("FromDate") as RadDatePicker).SelectedDate;
                        this.endDate = ((e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("ToDate") as RadDatePicker).SelectedDate;
                        break;
                    default:
                        break;
                }
 
 
            }

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 09 Oct 2013, 03:23 PM
Hi Tal,

The issue you are experiencing is caused due to the "he-IL" Culture you are using and the date formats. Please try to add the following in your Page directive and see if it makes any difference. On my side this solved the issue:
<%@ Page Language="C#" Culture="he-IL" UICulture="he-IL" ....

Furthermore, please take a look at our online demo for range filtering with DateTimeColumn:

Hope that helps.

 

Kind Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
0
Tal
Top achievements
Rank 1
answered on 09 Oct 2013, 04:33 PM
Hi
Unfortinately this did not solve my problem.
Other suggestions please?
       <telerik:GridDateTimeColumn FilterControlWidth="150px" DataField="date" HeaderText="תאריך"
                    SortExpression="date" UniqueName="date1" PickerType="DatePicker"
                    EnableRangeFiltering="true">
                    <HeaderStyle Width="160px"></HeaderStyle>
                </telerik:GridDateTimeColumn>
Thanks
0
Konstantin Dikov
Telerik team
answered on 12 Oct 2013, 08:33 AM
Hi Tal,

Since I am not able to replicate the issue on my end with our latest RadControls version, could you please elaborate what version you are using.

Additionally, attached you could find a sample project with range filtering on GridDateTimeColumn that works as expected. Please have a look and see what differs in your project.

If you continue to experience the issue, please open a regular support ticket with sample, runnable project that replicates the problematic area attached, so we could inspect is locally. 

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Tal
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Tal
Top achievements
Rank 1
Share this question
or