首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqGrid :来自java spring boot的数据

jqGrid :来自java spring boot的数据
EN

Stack Overflow用户
提问于 2018-07-21 18:32:23
回答 1查看 578关注 0票数 0
代码语言:javascript
复制
<!DOCTYPE html>

<html lang="en">
<head>
    <!-- The jQuery library is a prerequisite for all jqSuite products -->
    <script type="text/ecmascript" src="js/jquery.min.js"></script> 
    <!-- This is the Javascript file of jqGrid -->   
    <script type="text/ecmascript" src="js/jquery.jqGrid.min.js"></script>
    <!-- This is the localization file of the grid controlling messages, labels, etc. -->
    <!-- We support more than 40 localizations -->
    <script type="text/ecmascript" src="js/i18n/grid.locale-en.js"></script>
    <!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui.min.css" />
    <!-- The link to the CSS that the grid needs -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
    <meta charset="utf-8" />
    <title>jqGrid Loading Data - JSON</title>
</head>
<body>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
<script type="text/javascript"> 

当我使用json文件时,它可以工作:

代码语言:javascript
复制
$(document).ready(function () {

        $("#jqGrid").jqGrid({
        url: 'data.json',
        datatype: "json",
        colModel: [
           { label: 'FirstName', name: 'FirstName', width: 175 },
           { label: 'LastName', name: 'LastName', width: 190 }                   
        ],

        viewrecords: true, // show the current page, data rang and total records on the toolbar
        width: 780,
        height: 200,
        rowNum: 30,
        loadonce: true, // this is just for the demo
        pager: "#jqGridPager"
    });
});

但是如果我使用后端应用程序的url (Spring boot JPA):

代码语言:javascript
复制
http://localhost:8080/customer

这是一张图片:

我将url替换为:

代码语言:javascript
复制
url: 'http://localhost:8080/customer',

jqgrid中没有记录?!!

这是一张图片:

EN

回答 1

Stack Overflow用户

发布于 2018-07-22 19:49:55

您可以在本地将jqgrid代码作为文件运行,而不是从服务器运行-即file:///.../index.html.。您应该通过示例从web服务器运行此代码,如下所示

代码语言:javascript
复制
http://localhost:8000/index.html

然后你可以使用你指向的url。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51455189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档