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

Demo - Client-side insert/update/delete

3 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Axe
Top achievements
Rank 1
Axe asked on 30 Aug 2008, 01:04 PM
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

3 Answers, 1 is accepted

Sort by
0
Axe
Top achievements
Rank 1
answered on 30 Aug 2008, 02:49 PM
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

0
Axe
Top achievements
Rank 1
answered on 31 Aug 2008, 09:26 AM
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
0
Nikolay Rusev
Telerik team
answered on 02 Sep 2008, 12:57 PM
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.
Tags
Grid
Asked by
Axe
Top achievements
Rank 1
Answers by
Axe
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or