IE7中的jqGrid错误

时间:2010-08-30 13:41:15

标签: javascript jquery internet-explorer jqgrid

我正在使用jqgrid,它目前在FF,IE8,Chrome,Safari中运行良好。但是在IE7中我收到了这个错误:

  

'this.rows.0.cells'为null或不是对象

     

jquery.jqGrid.min.js

     

代码:   0

     

行:122字符:278

有没有人来过这个?有没有已知的修复方法?

更新

这是我的PHP代码:

$qry = 'SELECT stock_num, shape, carat, clarity, color, cut 
        FROM rapnet_diamonds 
        WHERE (carat BETWEEN "0" AND "5") 
        AND (color BETWEEN "D" AND "Z") 
        AND ( CASE clarity 
            WHEN "FL" THEN 0 
            WHEN "IF" THEN 1 
            WHEN "VVS1" THEN 2 
            WHEN "VVS2" THEN 3 
            WHEN "VS1" THEN 4 
            WHEN "VS2" THEN 5 
            WHEN "SI1" THEN 6 
            WHEN "SI2" THEN 7 
            WHEN "I1" THEN 8 
            WHEN "I2" THEN 9 
            WHEN "I3" THEN 10 
            ELSE -1 END BETWEEN "0" AND "10") 
        AND ( CASE cut 
            WHEN "ideal" THEN 0 
            WHEN "excellent" THEN 1 
            WHEN "very good" THEN 2
            WHEN "good" THEN 3 
            WHEN "fair" THEN 4 
            WHEN "poor" THEN 5 
            ELSE -1 END BETWEEN "0" AND "5")';

$grid->SelectCommand = $qry;
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();


// Set grid caption using the option caption
$grid->setGridOptions(array(
    "caption"=>"Diamonds Found",
    "rowNum"=>200,
    "sortname"=>"diamond_id",
    "hoverrows"=>true,
    "sortable"=>0,
    "scroll"=>1,
    "height"=>300,
    "altRows"=>true,
    "colNames"=> array('ID', 'Shape', 'Carat', 'Clarity', 'Color', 'Cut')
    ));
// Change some property of the field(s)
$grid->setColProperty("diamond_id", array("label"=>"ID", "width"=>60));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;

以下是生成的内容:

<table id='grid'></table>
    <div id='pager'></div>
    <script type='text/javascript'>
    jQuery(document).ready(function() {jQuery('#grid').jqGrid({"width":"650","hoverrows":true,"viewrecords":true,"jsonReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"xmlReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"gridview":true,"url":"myfirstgrid.php?yellow=","editurl":"myfirstgrid.php?yellow=","cellurl":"myfirstgrid.php?yellow=","onSelectRow":function(rowid, selected) 
    { 
        if(rowid != null) { 
           // alert("selected: "+rowid);
           loadSelectedDiamond(rowid);
        } 
    } ,"gridComplete":function() 
    { 
        diamondsReloaded();
    } ,"caption":"Diamonds Found","rowNum":200,"sortname":"diamond_id","sortable":0,"scroll":1,"height":300,"altRows":true,"colNames":["ID","Shape","Carat","Clarity","Color","Cut"],"datatype":"json","colModel":[{"name":"stock_num","index":"stock_num","editable":true,"sorttype":"string","key":true},{"name":"shape","index":"shape","editable":true,"sorttype":"string"},{"name":"carat","index":"carat","editable":true,"sorttype":"numeric"},{"name":"clarity","index":"clarity","editable":true,"sorttype":"string"},{"name":"color","index":"color","editable":true,"sorttype":"string"},{"name":"cut","index":"cut","editable":true,"sorttype":"string"}],"postData":{"oper":"grid"},"prmNames":{"page":"page","rows":"rows","sort":"sidx","order":"sord","search":"_search","nd":"nd","id":false,"filter":"filters","searchField":"searchField","searchOper":"searchOper","searchString":"searchString","oper":"oper","query":"grid","addoper":"add","editoper":"edit","deloper":"del","excel":"excel","subgrid":"subgrid","totalrows":"totalrows"},"pager":"#pager"}); });
    </script>

我正在使用jqgrid版本3.8

1 个答案:

答案 0 :(得分:1)

在您发布测试解决方案的链接后,我可以自己检查一下这个问题。我可以看到主页面从URL http://www.kranichs.com/diamond_search/myfirstgrid.php加载数据。完整的获取请求看起来像http://www.kranichs.com/diamond_search/myfirstgrid.php?yellow=&oper=grid&_search=false&nd=1283196859096&rows=200&page=1&sidx=diamond_id&sord=asc。我还可以看到Fiddler关于将从服务器发回的数据不是正确的JSON数据。在我看来,这是你的主要问题。数据如下所示

4cb2
{"records":"136635","page":1,"total":684,"rows":[{...}]}
0

部分{"records":"136635","page":1,"total":684,"rows":[{...}]}是jqGrid需要的正确JSON数据。我使用http://www.trirand.net/demophp.aspx进行了测试,可以看到相同的问题,但是另一个页面http://www.trirand.net/demoaspnetmvc.aspx更贴近我没有问题

我建议您在遇到IE7问题的同一台计算机上测试演示页http://www.trirand.net/demophp.aspxhttp://www.trirand.net/demoaspnetmvc.aspx

我只是jqGrid的用户而不是jqGrid的开发者,所以如果你在jqGrid PHP版本中发现了一些问题,请将其发布到http://www.trirand.net/。我个人前一段时间买了ASP.NET MVC订阅的完整源代码,以支持jqGrid的开发人员(但现在只使用jqGrid的免费版本),所以我只能访问ASP.NET MVC代码,而不是PHP版本。因此,如果您的问题存在于PHP版本中,则必须在http://www.trirand.net/上发布到论坛。