Kendo UI甘特图没有加载数据

时间:2015-11-28 06:46:42

标签: java jsp spring-mvc kendo-ui kendo-gantt

我正在尝试在jsp文件中使用kendo ui gantt chart。我正在为项目使用spring mvc和maven。我正在按照春季演示中给出的教程,但我仍然没有得到结果。在jsp页面中没有显示任何内容。

JSP

<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags"%>   
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  

    <kendo:gantt name="gantt" height="700" showWorkDays="false" showWorkHours="false" snap="false">
        <kendo:gantt-views>
            <kendo:gantt-view type="day" />
            <kendo:gantt-view type="week" selected="true" />
            <kendo:gantt-view type="month"  />
        </kendo:gantt-views>

        <kendo:gantt-columns>
            <kendo:gantt-column field="id" title="ID" width="50" />
            <kendo:gantt-column field="title" title="Title" editable="true" />
            <kendo:gantt-column field="start" title="Start Time" format="{0:MM/dd/yyyy}" width="100" />
            <kendo:gantt-column field="end" title="End Time" format="{0:MM/dd/yyyy}" width="100" />
        </kendo:gantt-columns>

        <kendo:dataSource batch="false">
             <kendo:dataSource-schema>
                <kendo:dataSource-schema-model id="id">
                     <kendo:dataSource-schema-model-fields>
                         <kendo:dataSource-schema-model-field name="id" type="number" />
                         <kendo:dataSource-schema-model-field name="orderId" type="number" />
                         <kendo:dataSource-schema-model-field name="parentId" defaultValue="null" nullable="true" type="number" />
                         <kendo:dataSource-schema-model-field name="start" type="date" />
                         <kendo:dataSource-schema-model-field name="end" type="date" />
                         <kendo:dataSource-schema-model-field name="title" defaultValue="No title" type="string" />
                         <kendo:dataSource-schema-model-field name="percentComplete" type="number" />
                         <kendo:dataSource-schema-model-field name="expanded" type="boolean" defaultValue="true" />
                         <kendo:dataSource-schema-model-field name="summary" type="boolean" />
                    </kendo:dataSource-schema-model-fields>
                </kendo:dataSource-schema-model>
            </kendo:dataSource-schema>
            <kendo:dataSource-transport>

                <kendo:dataSource-transport-read url="/Gantt/tasks/read" dataType="json" type="POST" contentType="application/json" />

                <kendo:dataSource-transport-parameterMap>
                    <script>
                        function parameterMap(options, type) {
                            return JSON.stringify(options.models || [ options ]);
                        }
                    </script>
                </kendo:dataSource-transport-parameterMap>              
            </kendo:dataSource-transport>
        </kendo:dataSource>

        <kendo:dependencies batch="false">
             <kendo:dataSource-schema>
                <kendo:dataSource-schema-model id="id">
                     <kendo:dataSource-schema-model-fields>
                         <kendo:dataSource-schema-model-field name="id" type="number" />
                         <kendo:dataSource-schema-model-field name="predecessorId" type="number" />
                         <kendo:dataSource-schema-model-field name="successorId" type="number" />
                         <kendo:dataSource-schema-model-field name="type" type="number" />
                    </kendo:dataSource-schema-model-fields>
                </kendo:dataSource-schema-model>
            </kendo:dataSource-schema>
            <kendo:dataSource-transport>

                <kendo:dataSource-transport-read url="/Gantt/dependencies/read" dataType="json" type="POST" contentType="application/json" />

                <kendo:dataSource-transport-parameterMap>
                    <script>
                        function parameterMap(options, type) { 
                            return JSON.stringify(options.models || [ options ]);
                        }
                    </script>
                </kendo:dataSource-transport-parameterMap>              
            </kendo:dataSource-transport>
        </kendo:dependencies>
    </kendo:gantt>

控制器

@Controller
public class IndexController {
    @Autowired 
    private GanttTaskDao taskDao;

    @Autowired 
    private GanttDependencyDao dependencyDao;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(Locale locale, Model model) {        
        return "index";
    }

    @RequestMapping(value = "/tasks/read", method = RequestMethod.POST)
    public @ResponseBody List<GanttTask> read_tasks() {
        return taskDao.getList();
    }
    @RequestMapping(value = "/dependencies/read", method = RequestMethod.POST)
    public @ResponseBody List<GanttDependency> read_dependencies() {
        return dependencyDao.getList();
    }
}

我还使用调试模式来运行项目,但是请求只到/ index方法,没有请求发送到/ gantt / tasks / read或/ gantt / dependency / read方法。

我尝试使用不同的网址,以防可能存在一些错误。但它仍无法正常工作。

我不知道我哪里出错了。有人知道答案。还有什么我可能会失踪吗?

1 个答案:

答案 0 :(得分:0)

好吧我做了一些愚蠢的错误我忘了将js和css文件包含到我的jsp中。我现在把它包括在内。当我使用调试模式时,它正在检索任务和依赖项,但它没有在我的jsp中显示它。我只能看到空图表窗口。请有人帮忙。