Client Databind Fails/Hangs with DataFormatString {0:g}

4 posts, 0 answers
  1. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 22 Feb 2011 Link to this post

    I have a RadGrid where one of the columns binds to a date/time value.  I use a GirdDataBound column and it binds correctly on the server.  Using the same source for the data, this fails when I try to bind on the client.  It shows the first record, then just stops. The lines that follow in the Javascript function do not execute.

    I removed the DataFormatString and it worked. 

    To work around this, I changed the column to a string and formatted it before sending it out to be bound.

    I know I'll trip on this again some day (probably soon), so I'd like to get a resolution.

    Thanks.
  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 28 Feb 2011 Link to this post

    Hello,

    This happens because javascript does not support the format strings that the .NET framework does. You can learn more on date formatting in javascript from this blog post:
    JavaScript Date Format

    Greetings,
    Tsvetina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 28 Feb 2011 Link to this post

    Understood, but don't you see this as a failure on the RadGrid?  I would imagine that it shouldn't attempt to re-bind on the client using the server-side format string if it's known not to be compatible and that it might cause a failure. 

    Is there a workaround in that I can provide a server-side format string and a client-side format string?

    Thank you.
  5. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 07 Mar 2011 Link to this post

    Hello,

    In order to inspect the issue further and see if it is a bug we would need to debug a runnable project and see what happens during the execution of the script. If you want us to go on investigating this, please provide us with a sample project replicating the described issue.

    As for a work-around, you can consider using a format string which is also recognizable by javascript, like, for example {0:d}.

    All the best,
    Tsvetina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top