+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Event Start Date is not shown correctly

Event Start Date is not shown correctly

8 posts, 0 answered
  1. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    08 Nov 2010
    Link to this post
    I added the 'Event_Start' column on the event listing page in admin, 'EventsItemsList.ascx'. One thing I noticed is that the datetime is not shown correctly, 8 hours late. e.g. If the event starts at 25 Nov 2010, 11:45 AM, it shows 25 Nov 2010, 7:45 PM on the listing page. It shows correctly on the detail and summary page in admin though. Can you help? Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Nov 2010
    Link to this post
    Hi Stephen,

    You should resolve the Event_Start and Event_End value depending on the current UI culture. You have to modify the template you have mapped EventsItemsList.ascx and its RowDataBound function

    function RadGrid_RowDataBound(sender, args) {
      var dataItem = args.get_dataItem();
        var item = args.get_item();
        var columns = item.get_owner().get_columns();
        var cells = args.get_item().get_element().cells;
         
        if(dataItem['IsLocked'] == true) {
            args.get_item().get_element().className = "cms_locked";
        }
        else {
            args.get_item().get_element().className = "";
        }
         
        for (var i = 0; i < cells.length; i++) {
            var cell = cells[i];
            var html = gridTemplates.Replace(columns[i].get_element().UniqueName, dataItem);
            if (html != null)
                if( html != "")
                  var date = null;
                     
                    if(elementName == 'Event_Start') {
                        date = new Date(dataItem['MetaFields'].Publication_Date);
                    }
                    else if (elementName == 'Event_End') {
                        date = new Date(dataItem['MetaFields'].Expiration_Date);
                    }
     
                    if (date && !isNaN(date)) {
                        html = date._toFormattedString('dd MMM yyyy, hh:mm tt', Sys.CultureInfo.CurrentCulture);
                    }
                     
                    cell.innerHTML = html;
                }
                else {
                    cell.innerHTML = " ";
                }
        }


    Regards,
    Ivan Dimitrov
    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
  3. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    08 Nov 2010
    Link to this post
    I tried that, but the problem is still not resolved.

    function RadGrid_RowDataBound(sender, args) {
                    var dataItem = args.get_dataItem();
                    var item = args.get_item();
                    var columns = item.get_owner().get_columns();
                    var cells = args.get_item().get_element().cells;
     
                    if (dataItem['IsLocked'] == true) {
                        args.get_item().get_element().className = "cms_locked";
                    }
                    else {
                        args.get_item().get_element().className = "";
                    }
     
                    for (var i = 0; i < cells.length; i++) {
                        var cell = cells[i];
                        var elementName = columns[i].get_element().UniqueName;
                        var html = gridTemplates.Replace(elementName, dataItem);
                        if (html != null)
                            if (html != "") {
                            var date = null;
     
                            if (elementName == 'Event_Start') {
                                date = new Date(dataItem['MetaFields'].Event_Start);
                            }
                            else if (elementName == 'Event_End') {
                                date = new Date(dataItem['MetaFields'].Event_End);
                            }
     
                            if (date && !isNaN(date)) {
                                html = date._toFormattedString('dd MMM yyyy, hh:mm tt', Sys.CultureInfo.CurrentCulture);
                            }
     
                            cell.innerHTML = html;
                        }
                        else {
                            cell.innerHTML = " ";
                        }
                    }
     
                    // disable delete if needed
                    if (dataItem['IsDisabled'] == true || (allowDelete.toLowerCase() == 'false' && dataItem['IsOwner'] == false)) {
                        $(args.get_item().get_element()).children(".delete").children("a").removeAttr("href");
                        $(args.get_item().get_element()).children(".deleteDis").children("a").removeAttr("href");
                        $(args.get_item().get_element()).children(".delete").addClass("deleteDis");
                        $(args.get_item().get_element()).children(".delete").removeClass("delete");
                    }
                    else {
                        $(args.get_item().get_element()).children(".deleteDis").addClass("delete");
                        $(args.get_item().get_element()).children(".deleteDis").removeClass("deleteDis");
                    }
     
                    // disabled edit if needed
                    if (dataItem['IsDisabled'] == true || (allowModify.toLowerCase() == 'false' && dataItem['IsOwner'] == false)) {
                        $(args.get_item().get_element()).children(".edit").children("a").removeAttr("href");
                        $(args.get_item().get_element()).children(".editDis").children("a").removeAttr("href");
                        $(args.get_item().get_element()).children(".edit").addClass("editDis");
                        $(args.get_item().get_element()).children(".edit").removeClass("edit");
                    }
                    else {
                        $(args.get_item().get_element()).children(".editDis").addClass("edit");
                        $(args.get_item().get_element()).children(".editDis").removeClass("editDis");
                    }
                }
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Nov 2010
    Link to this post
    Hi Stephen,

    Please take a look at this post and check the current culture by using the js code provided there.

    Sincerely yours,
    Ivan Dimitrov
    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
  5. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    09 Nov 2010
    Link to this post
    I followed the instructions in the post and found out the date format is fine. The issue is that the event_start dates on the EventsItemsList.ascx control are showing incorrect values.

    I removed the date format in the control and get the event_start dates as following. Is it a bug or I did something wrong? Thanks.

    if (elementName == 'Event_Start') {
                                date = new Date(dataItem['MetaFields'].Event_Start);
                            }
                            else if (elementName == 'Event_End') {
                                date = new Date(dataItem['MetaFields'].Event_End);
                            }
     
                            if (date && !isNaN(date)) {
                                html = date;   //date._toFormattedString('dd MMM yyyy, hh:mm tt', Sys.CultureInfo.CurrentCulture);
                            }
     
                            cell.innerHTML = html;
    .
    Results like following
    xxxxxx Tue Nov 16 2010 01:00:00 GMT-0800 (Pacific Standard Time)  --  Event start date should 8 hours earlier
    xxxxxx Thu Oct 21 2010 18:45:00 GMT-0700 (Pacific Daylight Time)  --  Event start date should 7 hours earlier
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Nov 2010
    Link to this post
    Hello Stephen,

    There is no a bug. The date  - Date is resolved depending on the culture Sys.CultureInfo.CurrentCulture which is the standard Microsoft Ajax object.

    Kind regards,
    Ivan Dimitrov
    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
  7. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    09 Nov 2010
    Link to this post
    How can I fix the date on the event listing page? It seems not an issue on other pages (frontend and backend like event summary, event edit page). Thanks again for your quick response.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Nov 2010
    Link to this post
    Hi Stephen,

    You can convert the returned dates to your time zone


    Regards,
    Ivan Dimitrov
    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
Register for webinar
8 posts, 0 answered