DataFormatString not persisted after Client DataBind

5 posts, 0 answers
  1. Marc
    Marc avatar
    12 posts
    Member since:
    May 2008

    Posted 12 Dec 2008 Link to this post

    Hello,
    DataFormatString works fine if I bind the datasource on the server, however after a client side bind DataFormatString no longer seems to be applied.
    For Example: 18/10/2007 Changes to: Thu Oct 18 2007 00:00:00 GMT-0400 (Eastern Daylight Time) after a sort, paging etc.

    Column Tag:

    <
    telerik:GridBoundColumn HeaderText="Date of Service" SortExpression="ClaimDateOfService" DataFormatString="{0:dd/MM/yyyy}" DataType="System.DateTime" DataField="ClaimDateOfService" />                                                        


    OnCommand:

     

     


    function grdMemberClaims_Command(sender, args)  
    {  
        var currentPageIndex = sender.get_masterTableView().get_currentPageIndex();  
        var pageSize = sender.get_masterTableView().get_pageSize();  
        var sortExpressions = sender.get_masterTableView().get_sortExpressions();      
        sender.get_masterTableView().clearSelectedItems();  
        if(sortExpressions.length > 0 && currentPageIndex > 0)      
            sender.get_masterTableView().set_currentPageIndex(0);      
        var sortExpressionssortExpressionsAsSQL = sortExpressions.toString();                            
        MemberInquiryService.GetMemberClaimsByMemberId("<%=MemberId %>",currentPageIndex * pageSize, pageSize, sortExpressionsAsSQL, GetMemberClaimsByMemberIdCompleted);           
        logDebug("MemberInquiryService", "GetMemberClaimsByMemberId",  "MemberId=<%=MemberId %>" + " PageSize=" + pageSize + " ResultOffset=" +(currentPageIndex * pageSize) +" SortExpression="+sortExpressionsAsSQL);                       
        args.set_cancel(true);  


    Do I need to reset the DataFormatString in the OnCommand Event Handler, how would I do that.
    If not is there a workaround?
    This is happening with all formated columns Decimals etc.

    Thanks,
    Marc

  2. Marc
    Marc avatar
    12 posts
    Member since:
    May 2008

    Posted 15 Dec 2008 Link to this post



    function GetMemberClaimsByMemberIdCompleted(result)  
    {  
        var tableView = $find("<%= grdMemberClaims.ClientID %>").get_masterTableView();                   
        tableView.set_virtualItemCount(result.TotalRecordCount);  
        tableView.set_dataSource(result.Records);        
        tableView.clearSelectedItems();  
        tableView.dataBind();      
        logDebug("MemberInquiryService", "GetMemberClaimsByMemberId_Completed", "TotalRecordCount=" + result.TotalRecordCount);      


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 16 Dec 2008 Link to this post

    Hello Marc,

    Unfortunately I was not able to replicate the issue on my end.
    For your convenience I am sending you sample application which seems to be working properly on my end.
    You can see that Date column shows always formatted data.

    Please make sure that you are using latest build of RadControls for ASP.NET AJAX.

    I hope this helps. 

    Sincerely yours,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Marc
    Marc avatar
    12 posts
    Member since:
    May 2008

    Posted 16 Dec 2008 Link to this post

    Thanks for the response Nikolay,

    In your attached example you use the SelectMethod to do your databinding, I am however intercepting the  OnCommand ClientEvent and passing the criteria, offset, pagesize, and sortexpression manually like you guys suggest in this article  "Non-declarative client-side binding".

    I bind the grid on the server originally, but any events caught by the Grids OnCommand Client Event cause my webservice to get called and when that completes and I bind the returned results the format of my DateTimes and decimal change.







  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 17 Dec 2008 Link to this post

    Hello Marc,

    Unfortunately I am not sure how to replicated this on my end.
    Can you please check the following example. It demonstrates another approach of client-side data-binding
    and you can see that BirthDate column has DataFormatString:
    $find("RadGrid1").get_masterTableView().get_columns()[5]._data.DataFormatString 

    Client-side data-binding

    However I suggest you to use new RadGrid feature Declarative client-side data-binding.

    I hope this helps.

    Best wishes,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017