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

how to update the data of dataSource

2 Answers 4094 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Ikou
Top achievements
Rank 1
Ikou asked on 19 Oct 2015, 09:40 AM

Hello,

 

I want to mass update the data of dataSource in JSON.
If you run in the following way, it seems well data is not set.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Kendo UI Snippet</title>
 
 
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
   
<div id="gantt"></div>
<script>
   
  var dataSource =new kendo.data.GanttDataSource({
    data: [
      {
        "id": 0,
        "orderId": 0,
        "parentId": null,
        "title": "old task1",
        "start": "2015-10-19",
        "end": "2015-10-20"
      },
      {
        "id": 1,
        "orderId": 0,
        "parentId": null,
        "title": "old task2",
        "start": "2015-10-19",
        "end": "2015-10-20"
       }
      ]
  });
   
$("#gantt").kendoGantt({
  dataSource: dataSource,
  views: ["week"],
  columns: [
    { field: "title", title: "Title" },
    { field: "id", title: "ID" }
  ]
});
   
dataSource.fetch(function(){
  dataSource.data([
    {
      "id": 0,
      "orderId": 0,
      "parentId": null,
      "title": "new task1",
      "start": "2015-10-19",
      "end": "2015-10-20"
    },
    {
      "id": 1,
      "orderId": 0,
      "parentId": null,
      "title": "new task2",
      "start": "2015-10-19",
      "end": "2015-10-20"
    }
  ]);
});
   
</script>
</body>
</html>

 

Date is not displayed well as attached image.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar Terziev
Telerik team
answered on 21 Oct 2015, 06:28 AM
Hello,

In order to change the content of the data source, the appropriate approach would be to use the setDataSource method and pass a new instance of the data source containing the new data. Here is a dojo snippet. The fetch method is used to fetch data from a remote service as stated in our online documentation.

Regards,
Dimitar Terziev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ikou
Top achievements
Rank 1
answered on 22 Oct 2015, 02:41 AM
Well I was able to understand.
Thank you!
Tags
Gantt
Asked by
Ikou
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Ikou
Top achievements
Rank 1
Share this question
or