Kendo UI甘特图未加载数据



我正在尝试在jsp文件中使用kendo-ui-gantt图表。我在这个项目中使用springmvc和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方法,并且没有请求发送到/gant/tasks/read或/gantt/dependency/read方法。

我尝试使用不同的url,以防出现错误。但它仍然不起作用。

我不知道我哪里错了。任何人都知道答案。还有什么我可能遗漏的吗?

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

最新更新