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

Grid JSON file edit

4 Answers 289 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kirill
Top achievements
Rank 1
Kirill asked on 12 May 2016, 03:02 PM

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.

 

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 13 May 2016, 07:18 AM
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!
 
0
Kirill
Top achievements
Rank 1
answered on 17 May 2016, 09:22 AM

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.

 

0
Kirill
Top achievements
Rank 1
answered on 17 May 2016, 09:43 AM

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. 

0
Kiril Nikolov
Telerik team
answered on 18 May 2016, 07:18 AM
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!
 
Tags
Grid
Asked by
Kirill
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Kirill
Top achievements
Rank 1
Share this question
or