为什么我无法在HTML上呈现jqGrid

时间:2022-09-03 23:18:37

I'm trying to render a jqGrid on HTML, but facing some errors. Here is the full code. I am getting a run-time error, and the grid is not loading.

我正在尝试在HTML上呈现jqGrid,但面临一些错误。这是完整的代码。我收到运行时错误,网格没有加载。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="/Scripts/jquery-1.3.2.js" type="text/javascript"></script>    
   <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

    <link rel="stylesheet" type="text/css" href="/Scripts/themes/steel/grid.css" title="steel"media="screen" />

    <link href="/Scripts/themes/jqModal.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery.jqGrid.js" type="text/javascript"></script>
    <script src="/Scripts/js/jqModal.js" type="text/javascript"></script>
    <script src="/Scripts/js/jqDnR.js" type="text/javascript"></script>
    <script type="text/javascript">

    function() {

     var lastsel2 =
jQuery("#tempset").jqGrid({
    datatype: "local",
    height: 260,
    width:300,
       colNames:[ ' ','Rate *C/Min','Value *C', 'Hold Time min', 'Run Time min'],
       colModel:[
           {name:'id',index:'id', width:60, sorttype:"int", editable: true},
           {name:'rate',index:'rate', width:40,editable: true,editoptions:{size:"20",maxlength:"30"}},
           {name:'value',index:'value', width:40, editable: true,editoptions: {size:"20",maxlength:"30"}},
           {name:'holdtime',index:'holdtime', width:50, editable: true,editoptions:{size:"20",maxlength:"30"}},        
           {name:'runtime',index:'runtime', width:100,editable: false}        
       ],
    onSelectRow: function(id){
        if(id && id!==lastsel2){
            jQuery('#tempset').jqGrid('restoreRow',lastsel2);
            jQuery('#tempset').jqGrid('editRow',id,true);
            lastsel2=id;
        }
    },
    //editurl: "server.php",
    caption: "Temperature Settings",
    pager: "#tempset_pager",
});

var mydata2 = [
        {id:"initial",rate:"",value:"50",holdtime:"60",runtime:"60"},
        {id:"Ramp 1",rate:"15",value:"67 ",holdtime:"5",runtime:"66.133"},
        {id:"Ramp 2",rate:"20",value:"89",holdtime:"10",runtime:"77.233"},
        {id:"Ramp 3",rate:"25",value:"123",holdtime:"3",runtime:"81.593"}
        ];

for(var i=0;i < mydata2.length;i++)
{
//alert(mydata2[i].id);
 jQuery("#tempset").jqGrid('addRowData',mydata2[i].id,mydata2[i]);
 }

 jQuery("#tempset").navGrid("#tempset_pager", {});

 }

</script>
</head>


<body>
<div style = "margin-left:240px; top: 15px; position:absolute;">
 <table id="tempset"></table>
        <div id="tempset_pager"> </div>
 </div>


</body>
</html>

3 个解决方案

#1


1  

The following might be causing issues :

以下可能导致问题:

  1. Multiple references to jQuery.
  2. 对jQuery的多个引用。
  3. function() { ... -> this is a syntax error. function name is missing.
  4. function(){... - >这是一个语法错误。功能名称丢失。
  5. pager: "#tempset_pager", -> trailing comma would give error in IE
  6. pager:“#tempset_pager”, - >尾随逗号会在IE中出错

#2


0  

Replace this

替换它

function() {

with this

有了这个

$(function(){

Also, replace var lastsel2 = with either var lastsel2; or var lastsel2 = ''; and try again.

另外,将var lastsel2 =替换为var lastsel2;或var lastsel2 ='';然后再试一次。

#3


0  

Replace your

替换你的

function() { 

with this

有了这个

$(function(){

and add this closing brace like shown below at the end of your script code

并在脚本代码的末尾添加如下所示的右括号

);

Also replace

也替换

var lastsel2 = 

with

var lastsel2;

Note : After making the above mentioned changes its working for me

注意:完成上述更改后,它为我工作

#1


1  

The following might be causing issues :

以下可能导致问题:

  1. Multiple references to jQuery.
  2. 对jQuery的多个引用。
  3. function() { ... -> this is a syntax error. function name is missing.
  4. function(){... - >这是一个语法错误。功能名称丢失。
  5. pager: "#tempset_pager", -> trailing comma would give error in IE
  6. pager:“#tempset_pager”, - >尾随逗号会在IE中出错

#2


0  

Replace this

替换它

function() {

with this

有了这个

$(function(){

Also, replace var lastsel2 = with either var lastsel2; or var lastsel2 = ''; and try again.

另外,将var lastsel2 =替换为var lastsel2;或var lastsel2 ='';然后再试一次。

#3


0  

Replace your

替换你的

function() { 

with this

有了这个

$(function(){

and add this closing brace like shown below at the end of your script code

并在脚本代码的末尾添加如下所示的右括号

);

Also replace

也替换

var lastsel2 = 

with

var lastsel2;

Note : After making the above mentioned changes its working for me

注意:完成上述更改后,它为我工作