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

[Solved] Problem filtering Grid on DateTime column

3 Answers 202 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nick
Top achievements
Rank 1
Nick asked on 08 Apr 2010, 12:40 PM
I have migrated from build 2010.1.222 to the full release 2010.1.309 and am now having some issues with filtering on the grid.

I have my localisation set to en-GB as we're in the UK.  My column is declared as follows:
Dim colTimeStamp As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, Date)(grid, Function(a) a.DateStamp) 
colTimeStamp.Title = "DateStamp" 
colTimeStamp.Format = "{0:dd/MM/yyyy HH:mm}" 
The dates are displayed in the grid correctly and now the dates in the filter popup show in the same format (see my earlier question about this issue)

The problem is the page is still treating these dates as if they were in US format. For instance if I try and filter the grid to all records from yesterday it tries to query for all records after July 4th rather than April 7th  :(

How can I get the grid to utilise the UICulture settings for the page?  The web.config declares both the culture and uiCulture as en-GB.

My full grid declaration is:
    Dim grid As Telerik.Web.Mvc.UI.Grid(Of PortalAudit) = Html.Telerik.Grid(Of PortalAudit) _ 
                                                              .Name("AuditGrid") _ 
                                                              .Pageable(Function(p) p.Total(CInt(ViewData("Total")))) _ 
                                                              .Sortable() _ 
                                                              .Filterable() _ 
                                                              .EnableCustomBinding(True) _ 
                                                              .ClientEvents(Function(events) events.OnError("onGridError")) _ 
                                                              .DataBinding(Function(d) d.Ajax.Select("AuditListing""Audit")) 
    grid.Paging.PageSize = 20 
    Dim colUserName As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, String)(grid, Function(a) a.UserName) 
    Dim colAction As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, String)(grid, Function(a) a.Action) 
    Dim colController As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, String)(grid, Function(a) a.Controller) 
    colController.Title = "Area" 
    Dim colAffectedEntity As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, String)(grid, Function(a) a.AffectedEntity) 
    Dim colStatus As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, Boolean)(grid, Function(a) a.Status) 
    Dim colDescription As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, String)(grid, Function(a) a.Description) 
    Dim colTimeStamp As New Telerik.Web.Mvc.UI.GridBoundColumn(Of PortalAudit, Date)(grid, Function(a) a.DateStamp) 
    colTimeStamp.Title = "DateStamp" 
    colTimeStamp.Format = "{0:dd/MM/yyyy HH:mm}" 
    grid.Columns.Add(colUserName) 
    grid.Columns.Add(colController) 
    grid.Columns.Add(colAction) 
    grid.Columns.Add(colAffectedEntity) 
    grid.Columns.Add(colStatus) 
    grid.Columns.Add(colDescription) 
    grid.Columns.Add(colTimeStamp) 
    grid.Render() 
 

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 08 Apr 2010, 12:45 PM
Hi Nick,

You can try the following:
  1. Make sure the Globalization(true) is called for your ScriptRegistrar. This is required in order to serialize the current culture's date formats. The grid is using them to parse the date.
  2. If this does not help you can try the build attached in this forum thread. It addresses a few issues related with filtering and may help.

Regards,
Atanas Korchev
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
Nick
Top achievements
Rank 1
answered on 08 Apr 2010, 03:03 PM
Hi Atanas,

I have modified the script registrar instantiation in my master page to enable globalisation as follows:

    Dim scripts = Html.Telerik.ScriptRegistrar
    scripts.DefaultGroup(Function(group) group.Add("jquery-ui-1.7.2.custom.min.js"))
    scripts.Globalization(True)
    scripts.Render()

The grid now renders the dates in UK format without the need for me to specify a specific formatting string, but the filter is still submitting the date as a US date.

I will try the newer build this afternoon if possible..

Thanks for the swift reply,
Nick

0
Nick
Top achievements
Rank 1
answered on 08 Apr 2010, 03:18 PM
Hi again  :)

I have upgraded the extensions to the 2010.1.329 build attached to your other forum thread and the problem has indeed been fixed.

Many thanks as always,
Nick

Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Nick
Top achievements
Rank 1
Share this question
or