1

我希望有人能提供帮助,因为我整个早上都在绞尽脑汁(我敢肯定这是我做过的愚蠢的事情)。

无论如何,我希望我们的一个系统中的数据显示在 JQGrid 中,我希望数据从一页加载,所以我使用 StringXML 功能,但是我遇到的问题是页面上没有显示任何内容,如果我包括这会显示一个警报,但即使所有文件都加载正常并且错误控制台中没有错误,网格也不会显示。

我已经粘贴了下面的代码,有什么明显的错误吗?

<HTML><HEAD>
<script type='text/javascript' src='includes/jquery/jquery-1.7.2.min.js'></script>
<script type='text/javascript' src='includes/jquery/jquery-ui-1.8.22.custom.min.js'></script>
<link rel="stylesheet" type="text/css" media="screen" href="includes/jquery/jquery-ui-1.8.22.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="includes/grid/ui.jqgrid.css" />
<script src="includes/grid/js/il8n/grid.locale-en.js" type="text/javascript"></script>
<script src="includes/grid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
</HEAD><BODY>
<SCRIPT>var liststr = "<?xml version='1.0' encoding='utf-8'?><GRIDDATA><ROWS>
<ROW><CELL>Fri 24 Aug 2012 17:19</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 18:20</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 19:21</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 20:22</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 21:23</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 22:24</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Fri 24 Aug 2012 23:25</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Sat 25 Aug 2012 00:26</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Sat 25 Aug 2012 01:27</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Sat 25 Aug 2012 02:28</CELL><CELL>5</CELL></ROW>
<ROW><CELL>Sat 25 Aug 2012 03:29</CELL><CELL>5</CELL></ROW>
</ROWS></GRIDDATA>";

jQuery(document).ready(function() {
            jQuery("#gridview").jqGrid({ 
            datatype: 'xmlstring', datastr: 'liststr', height: 250, 
            colNames:['Date', 'Lic1'], 
            colModel:[    
                {name:'date',index:'date', width:90, sorttype:'date'}, {name:'30300', index:'30300', width: 200, sorttype:'int'}],
            multiselect: true,
            caption: "Licenses in Use"
            })
        ;}
</SCRIPT>
4

1 回答 1

2

第一个:你应该有一个<div id="gridview"></div>和第二个:在:

jQuery(document).ready(function() {
            jQuery("#gridview").jqGrid({ 
            datatype: 'xmlstring', datastr: 'liststr', height: 250, 
            colNames:['Date', 'Lic1'], 
            colModel:[    
                {name:'date',index:'date', width:90, sorttype:'date'}, {name:'30300', index:'30300', width: 200, sorttype:'int'}],
            multiselect: true,
            caption: "Licenses in Use"
            })
        ;}

您错过了“jQuery(document).ready(”的最新括号,因此,您的代码应如下所示:

jQuery(document).ready(function() {
            jQuery("#gridview").jqGrid({ 
            datatype: 'xmlstring', datastr: 'liststr', height: 250, 
            colNames:['Date', 'Lic1'], 
            colModel:[    
                {name:'date',index:'date', width:90, sorttype:'date'}, {name:'30300', index:'30300', width: 200, sorttype:'int'}],
            multiselect: true,
            caption: "Licenses in Use"
            });
        });
于 2012-09-25T13:10:40.553 回答