lundi 2 décembre 2019

How to parse my JSON data to String in KENDO GRID?

how can i format this object Object to its actual values ? I want this json object to display its actual values in a specific kendo grid column . Can someone please help me and teach me how to do it ?

This is the image of the kendo grid with the result ,

enter image description here

While here is the code that I am using in my view . Can please someone help .

            contact : new kendo.data.DataSource({
            transport:{
                read:{
                    type: "GET",
                    url:"reservation/list",
                    dataType:"json",
                    contentType: "application/json; chartset=utf-8"
                },
                update: {
                    url: "contacts/update",
                    dataType: "json",
                    type: "POST"
                },
                destroy: {
                    url: "contacts/destroy",
                    dataType: "json",
                    type:"POST"
                },
                create: {
                    url: "contacts/store",
                    dataType: "json",
                    type:"POST"
                }
            },
            schema:{
                model:{
                    id:"id",
                    fields:{
                        Purpose:
                        {
                            type:"string",
                            validation:{required:true}
                        },
                        RoomID:
                        {
                            from: "RoomID.room_name",
                            type: "string"
                        },
                        Equipments:
                        {  
                            from: "Equipments",
                            type: "string"
                        },
                        start:
                        {
                            type:"date",
                            validation:{required:true}
                        },
                        end:
                        {
                            type:"date",
                            validation:{required:true}
                        },
                    }
                }
            },
            pageSize:10
        }),
        init : function(e){
            $("#grid").kendoGrid({
                dataSource: this.contact,
                selectable: true,
                height:600,
                editable: "popup",
                filterable: true,
                sortable: {
                            mode: "multiple",
                            allowUnsort: true,
                            showIndexes: true
                        },
                toolbar: ["search"],
                columns: [
                    { 
                        field: "Purpose",
                        title:"Purpose" 
                    },
                    { 
                        field: "RoomID",
                        title:"Room", 
                    },
                    { 
                        field: "Equipments",
                        title:"Equipments", 
                    },
                    { 
                        field: "start",
                        title:"Start",
                        //template: '#= kendo.toString(kendo.parseDate(start), "MM/dd/yyyy HH:mm:ss")#' 
                        format: "{0:MMM dd,yyyy hh:mm tt}",
                        parseFormats: ["yyyy-MM-dd'T'HH:mm.zz"]
                    },
                    { 
                        field: "end",
                        title:"End",
                        //template: '#= kendo.toString(kendo.parseDate(end), "MM/dd/yyyy HH:mm:ss")#'
                        format: "{0:MMM dd,yyyy hh:mm tt}",
                        parseFormats: ["yyyy-MM-dd'T'HH:mm.zz"] 
                    },
                            { 
                                command: ["edit", "destroy"],
                                title: " ", 
                                width: "250px" 
                            }
                        ],
                pageable:{
                    pageSize:10,
                    refresh:true,
                    buttonCount:5,
                    messages:{
                        display:"{0}-{1}of{2}"
                    }
                }
            });
        },
        });
       kendo.bind($("#whole"),model);
       model.init();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire