Demo - Client-side insert/update/delete

4 posts, 0 answers
  1. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 30 Aug 2008 Link to this post

    I was trying out the demo here: http://demos.telerik.com/aspnet/prometheus/Grid/Examples/Client/InsertUpdateDelete/DefaultCS.aspx and noticed that after the grid updates the datetime column (Birthdate) shows the date time formatted as UTC. Is there any way around this?
    In the demo: http://demos.telerik.com/aspnet/prometheus/Grid/Examples/Client/DataBinding/DefaultCS.aspx it doesn't seem to happen!

    Regards
  2. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 30 Aug 2008 Link to this post

    I was playing around with this at home and ended up adding a OnRowDataBound client event and formatting date in there:

    function

    RowDataBound(sender, args)
    {
    var birthdate = args.get_item().get_cell("BirthDate").innerHTML;
    args.get_item().get_cell(
    "BirthDate").innerHTML = String.format("{0:d}", new Date(birthdate));
    }

    I was just curious as to why one demo formatted the date and the other didn't after a client call. The only differnce I can see between them is the second one uses page web methods.

    Regards

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 31 Aug 2008 Link to this post

    What does grid.repaint do?
    I was looking at docs but couldn't find anything. The name sounds obvious but when I removed from sample everything still seems to work.

    Regards
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 02 Sep 2008 Link to this post

    Hello Axe,

    The difference in the format in BirthDate column after client-side data binding is caused because of the way DateTime is serialized on client.

    You can workaround this by parsing the collection before set it to dataSource property of any GridTableView as shown below

    function updateGrid(result)  
    {  
                    for (var i = 0; i < result.length; i++)   
                    {  
                        result[i].BirthDate = String.format("{0:MM/dd/yyyy}", result[i].BirthDate)  
                    }   
                    var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();  
                    tableView.set_dataSource(result);  
                    tableView.dataBind();                 


    Best wishes,
    NikR
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top