質問編集履歴
3
説明の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
```
|
65
|
-
【
|
65
|
+
【gntの内容】
|
66
66
|
[{"id":1,"text":"project #1","start_date":"2020-05-06","end_date":"2020-05-26","user":3,"duration":20,"parent":0,"progress":0},
|
67
67
|
{"id":2,"text":"Task #1","start_date":"2020-05-06","end_date":"2020-05-16","user":0,"duration":10,"parent":1,"progress":0},
|
68
68
|
{"id":3,"text":"Task #2","start_date":"2020-05-16","end_date":"2020-05-26","user":0,"duration":10,"parent":1,"progress":0}]
|
2
json.dataの内容をテキストベースに直しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -62,4 +62,7 @@
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
```
|
65
|
-
|
65
|
+
【'json.data'の内容】
|
66
|
+
[{"id":1,"text":"project #1","start_date":"2020-05-06","end_date":"2020-05-26","user":3,"duration":20,"parent":0,"progress":0},
|
67
|
+
{"id":2,"text":"Task #1","start_date":"2020-05-06","end_date":"2020-05-16","user":0,"duration":10,"parent":1,"progress":0},
|
68
|
+
{"id":3,"text":"Task #2","start_date":"2020-05-16","end_date":"2020-05-26","user":0,"duration":10,"parent":1,"progress":0}]
|
1
コード部分を見やすいように変更しました。読み込みたいjsonファイル内容の画像を添付しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,50 +11,55 @@
|
|
11
11
|
使用ツール:DHTMLX Gantt (URL:https://docs.dhtmlx.com/gantt/ )
|
12
12
|
|
13
13
|
【コード】
|
14
|
-
|
14
|
+
<index.cshtml>
|
15
|
+
```Javascript
|
15
|
-
|
16
|
+
<script type="text/javascript" >
|
16
|
-
|
17
|
+
function jsonExport() {
|
17
|
-
|
18
|
+
var json = new Object();
|
18
|
-
|
19
|
+
json = gantt.serialize('json');
|
19
|
-
|
20
|
+
var gnt = JSON.stringify(json.data);
|
20
|
-
|
21
|
+
alert(gnt);
|
21
|
-
|
22
|
+
var aj = '@Url.Action("JSONTest")';
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
$.ajax(
|
25
|
-
|
25
|
+
{
|
26
|
-
|
26
|
+
type: 'POST',
|
27
|
-
|
27
|
+
url: aj,
|
28
|
-
|
28
|
+
data: gnt,
|
29
|
-
|
29
|
+
dataType: 'json',
|
30
|
-
|
30
|
+
contentType: 'application/json',
|
31
|
-
|
32
|
-
error: function () { },
|
33
|
-
complete: function (data) { alert(data.responseText) }
|
34
|
-
}
|
35
|
-
);
|
36
|
-
}
|
37
|
-
</script>
|
38
31
|
|
32
|
+
error: function () { },
|
33
|
+
complete: function (data) { alert(data.responseText) }
|
34
|
+
}
|
35
|
+
);
|
36
|
+
}
|
37
|
+
</script>
|
38
|
+
```
|
39
39
|
[HomeControllers.cs]
|
40
|
+
```C#
|
40
|
-
|
41
|
+
public ActionResult JSONTest(Data viewModel,Object son)
|
41
|
-
|
42
|
+
{
|
42
|
-
|
43
|
+
string[] vs = new string[4];
|
43
|
-
|
44
|
+
vs[0] = viewModel.Text;
|
44
|
-
|
45
|
+
vs[1] = viewModel.StartDate.ToString();
|
45
|
-
|
46
|
+
vs[2] = viewModel.EndDate.ToString();
|
46
|
-
|
47
|
+
vs[3] = viewModel.Duration.ToString();
|
47
|
-
|
48
|
+
return Json(vs);
|
48
|
-
|
49
|
+
}
|
50
|
+
```
|
49
51
|
[Data.cs(Model)]
|
52
|
+
```C#
|
50
53
|
namespace GantDHT.Models
|
51
54
|
{
|
52
|
-
|
55
|
+
public class Data {
|
53
56
|
|
54
|
-
|
57
|
+
public int Id { get; set; }
|
55
|
-
|
58
|
+
public string Text { get; set; }
|
56
|
-
|
59
|
+
public DateTime StartDate { get; set; }
|
57
|
-
|
60
|
+
public DateTime EndDate { get; set; }
|
58
|
-
|
61
|
+
public int Duration { get; set; }
|
59
|
-
|
62
|
+
}
|
60
|
-
|
63
|
+
}
|
64
|
+
```
|
65
|
+

|