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

Formatting Date type Xml nodes In kendo datasource

1 Answer 193 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Dimantha
Top achievements
Rank 1
Dimantha asked on 24 Sep 2012, 05:42 AM
Hi All,

I am binding Xml data to a grid. Following is the script I used to create the grid. In that script there is a one field TimeCreated which the type is in date format  and the actual result of that field looks like
"2012-09-21T21:59:26.6929846+05:30 " how can i format this to get the time part seperate and
date in "yyyy/MM/dd"(please note that i am using xml)





<script type="text/javascript">
            $(document).ready(function () {
                $("#grid").kendoGrid({
                    dataSource: new kendo.data.DataSource({


                        
                        transport: {
                           
                            read: "HandlerErrorLog.ashx"
                        },
                        pageSize: 8,
                        
                        schema: {
                         
                            type: "xml",
                           
                            data: "Errors/E2ETraceEvent",
                          
                            model: {
                              
                                fields: {
                                  
                                    TimeCreated: "System/TimeCreated/@SystemTime",


                                    ApplicationData: "ApplicationData/text()"
                                    
                                    
                                }
                            }
                        }
                    }),
                    scrollable: false,
                    sortable: true,
                    filterable: true,
                    selectable: "multiple row",
                    pageable:true
                    
                  
                });
               
            });
            </script>

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 27 Sep 2012, 07:41 AM
Hello Dimantha,

Did you try to declare the field's type as date and declare a column with format like in this demo:
http://demos.kendoui.com/web/grid/remote-data.html

e.g.
$(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "odata",
                            transport: {
                                read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
                            },
                            schema: {
                                model: {
                                    fields: {
                                        OrderID: { type: "number" },
                                        Freight: { type: "number" },
                                        ShipName: { type: "string" },
                                        OrderDate: { type: "date" },
                                        ShipCity: { type: "string" }
                                    }
                                }
                            },
                            pageSize: 10,
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        height: 250,
                        filterable: true,
                        sortable: true,
                        pageable: true,
                        columns: [{
                                field:"OrderID",
                                filterable: false
                            },
                            "Freight",
                            {
                                field: "OrderDate",
                                title: "Order Date",
                                width: 100,
                                format: "{0:MM/dd/yyyy}"
                            }, {
                                field: "ShipName",
                                title: "Ship Name",
                                width: 200
                            }, {
                                field: "ShipCity",
                                title: "Ship City"
                            }
                        ]
                    });
                });



Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Dimantha
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or