Grid JSON file edit

5 posts, 1 answers
  1. Kirill
    Kirill avatar
    3 posts
    Member since:
    May 2016

    Posted 12 May 2016 Link to this post

    Hello , 

    I'm preaty new to the programing and Kendo UI. But i have a task to make a grid and in it i should be able to edit/delete/update/create data in Json file.

    After watching  demo  a question popped up in my head.

    How does this part of code work : 

    var dataSource = new kendo.data.DataSource({

                transport: {

                           read: "/Products", update: {

                                         url: "/Products/Update",

                                         type: "POST"

                                  },

                             destroy: {

                                           url: "/Products/Destroy",

                                           type: "POST"

                                   },

                              create: {

                                     url: "/Products/Create",

                                    type: "POST"

                             }

     

    Specialy those parts with  [ url: "/Products/Create" ] .

    What should i do to get it ? I use XAMPP test server and use my URL which is  "localhost:8080/TestJson.json".

    Replacing it with my URL doesnt do much.

    var Pfad = "http://localhost:8080",
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: Pfad + "/TestJson.json",
                                    dataType: "json"
                                },
                                update: {
                                    url: Pfad + "/TestJson.json",
                                    dataType: "json",
                                    type: "POST"
                                },
                                destroy: {
                                    url: Pfad + "/TestJson.json",
                                    dataType: "json",
                                    type: "POST"
                                },
                                create: {
                                    url: Pfad + "/TestJson.json",
                                    dataType: "json",
                                    type: "POST"
                                },

    All it does is populate my Grid , but i can't edit or delete anything in that Json file.

    I know that it is wrong but i can't find a solution. Maybe there is a page where i can read about it.

     

     

  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 13 May 2016 Link to this post

    Hello,

    In the transport configuration of the Grid you need to specify the data endpoint (REST services) where the data will be fetched from or send for database persistance. I would suggest you to start with the following article in our documentation that I believe will give you a good start:

    http://docs.telerik.com/kendo-ui/controls/data-management/grid/overview

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kirill
    Kirill avatar
    3 posts
    Member since:
    May 2016

    Posted 17 May 2016 in reply to Kiril Nikolov Link to this post

    Hello again,

    I've done some more research and have another small problem.
    Now i don't get a proper response from the server. Here is my code :

    var Pfad = "http://localhost:3000",
                       dataSource = new kendo.data.DataSource({
                           autoSync: false,
                           transport: {
                               read: {
                                   url: Pfad + "/Data",
                                   dataType: "json"
                               },
                               update: {
                                   url: Pfad + "/Data",
                                   //type: "POST",
                                   dataType: "json"
                                    
                               },
                               destroy: {
                                   url: Pfad + "/Data",
                                   //type: "POST",
                                   dataType: "json"
                               },
                               create: {
                                   url: Pfad + "/Data",
                                   //type: "POST",
                                   dataType: "json"
                                    
                               },
                               parameterMap: function (option, operation) {
                                   if (operation !== "read" && option.models) {
                                       return kendo.stringify(option.models);
                                   }
                                   return kendo.stringify(option);
                               }
     
                           },

    When i update the data it sends JSON as it should :

    [{"id":2,"Vorname":"Martin","Nachname":"Markeloff","Alter":31,"Produkt":"Geforce GTX Titan X","Anzahl":10}]:""

    but the respons from server is just my whole JSON and in than i have two same names in GRID.

     

  4. Kirill
    Kirill avatar
    3 posts
    Member since:
    May 2016

    Posted 17 May 2016 in reply to Kirill Link to this post

    Sorry, i also forgot to mention that while using type: "GET", it doesnt save new data. With "POST" it doesn't update  GRID but save in JSON as new data.

     

    Once again sorry for taking your time , but got no where else to ask for help and explanation. 

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 18 May 2016 Link to this post

    Hi,

    The server response issue is not particularly related to Kendo UI, as it is a front-end component library. So I am not able to assist you with this matter as the server side code is out of scope for the support services.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top