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

DataFormatString not persisted after Client DataBind

4 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 2
Jon asked on 12 Dec 2008, 06:42 PM
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

4 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 2
answered on 15 Dec 2008, 05:11 PM


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);      


0
Nikolay Rusev
Telerik team
answered on 16 Dec 2008, 06:42 AM
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.
0
Jon
Top achievements
Rank 2
answered on 16 Dec 2008, 08:38 PM
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.







0
Nikolay Rusev
Telerik team
answered on 17 Dec 2008, 03:49 PM
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.
Tags
Grid
Asked by
Jon
Top achievements
Rank 2
Answers by
Jon
Top achievements
Rank 2
Nikolay Rusev
Telerik team
Share this question
or