Formatting Date type Xml nodes In kendo datasource

2 posts, 0 answers
  1. Dimantha
    Dimantha avatar
    2 posts
    Member since:
    Jun 2012

    Posted 24 Sep 2012 Link to this post

    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>
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 27 Sep 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top