2012-09-25 50 views
1

我希望有人可以幫忙,因爲我一直在這一整天早上絞盡腦汁(我確信這是我做的一些愚蠢的事情)。JQGrid for JQuery只是給了一個空白頁面

無論如何,我希望我們的系統中的數據能夠顯示在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> 
+0

我還沒有嘗試過,但可能它是大寫的標籤名 – Sonny

回答

2

1:你應該有一個<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(文檔)(」 所以,你的代碼看起來應該像這樣:

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" 
      }); 
     }); 
+0

非常感謝缺少的括號肯定沒有幫助,我發現在年底somethi數據問題? ng要知道每個人都確保你的ROW和CELL標籤在小寫字母!如果你像我的jqGrid那樣大寫它,它會忽略XMLSTRING數據。 – trevrobwhite

相關問題