IE8中可能存在jQuery / jqGrid问题 [英] Possible jQuery/jqGrid problem in IE8

查看:125
本文介绍了IE8中可能存在jQuery / jqGrid问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 jqGrid 构建的网格,它使用搜索工具栏,一个自定义格式化程序来插入 radio 框和 loadComplete 处理程序。
在FF中一切正常但是当我去IE8时(羞耻!!!)屏幕会因加载的数据和正在加载... 框而冻结屏幕。我在屏幕上什么都不做。

I have a grid constructed with jqGrid, that uses the search toolbar, a custom formatter to insert radio boxes and a loadComplete handler. Everything works fine in FF but when I go to IE8 (shame!!!) the screen would freeze with the data loaded and the Loading... box on the screen. I can do nothing on the screen.

这是我的代码:

function loadCompleteHandler(){
 jQuery("#listTable").jqGrid('setGridHeight', Math.min(300,parseInt(jQuery(".ui-jqgrid-btable").css('height'))));
}

 function radio(value, options, rowObject){
  var radio = '<input type="radio" value=' + value + ' name="radioid" ondblclick="inDetail();"/>';
  return radio;
 }

 function statusSelect(){
  #set($select = ":$l10n.lbl_123")
  #foreach($se in $status_list) 
   #set($select = $select + ";$se.getValue():$se.getValue()") 
  #end  
  return "$select";
 }

 jQuery(function(){  
  jQuery("#listTable").jqGrid({
     url: '$content.getURI("/servlet/ajax/MyServlet.json")' + '?loggedUserId=$loggedUserId&pageNo=0&locale=' + '$l10n.getLocale().toString()',
     datatype: 'json',
     mtype: 'POST',
     colNames:['','$l10n.lbl_copy','$l10n.lbl_476','$l10n.lbl_380', '$l10n.lbl_2547<br/>$l10n.lbl_3768','$l10n.lbl_owner','$l10n.lbl_256 $l10n.lbl_92','$l10n.lbl_1558<br>$l10n.lbl_185','$l10n.lbl_348'],
     colModel :[ 
        {name:'column1', index:'column1', width:'3%', search:false, align:'center', formatter: radio, editable:false, sortable: false, resizable:false},
        {name:'column2', index:'column2', width:'6%', search:false, align:'center', formatter:'checkbox', sortable: false, resizable:false}, 
        {name:'column3', index:'column3', width:'12%', sortable: false, stype:'select', editoptions:{value: statusSelect()}, resizable:false}, 
        {name:'column4', index:'column4', width:'17%', search:false, sortable: false, resizable:false}, 
        {name:'column5', index:'column5', width:'10%', search:false, sortable: false, resizable:false}, 
        {name:'column6', index:'column6', width:'13%', sortable: false, resizable:false}, 
        {name:'column7', index:'column7', width:'13%', sortable: false, resizable:false},
     {name:'column8', index:'column8', width:'12%', sortable: false, resizable:false},
     {name:'column9', index:'column9', width:'14%', sortable: false, resizable:false}
      ],
     width:'768',
  height: 300,
  loadonce:true,
  pager: '#pagerDiv',
  gridview: true,
  rowNum:15,
  rowTotal: 500,
     sortorder: 'desc',
     viewrecords: true,
  loadComplete: loadCompleteHandler
    }); 
 });

 jQuery(function(){
  jQuery("#listTable").jqGrid('filterToolbar',{
       stringResult: true, 
       searchOnEnter: false, 
       defaultSearch:'cn'}); /* search strategy meaning: contains */
 }); 

我使用的是Velocity,jQuery 1.4.2。 IE在此行的jQuery库
中给出了无效的参数错误:

I am using Velocity, jQuery 1.4.2. IE gives an invalid argument error in the jQuery library at this line:

 if ( set ) {
   style[ name ] = value;
  }

也许问题出在IE8中的jQuery,我不知道.. ..

Maybe the problem is with jQuery in IE8, I don't know....

编辑:添加了更具体的数据

EDIT : more specific data added

我使用的是jqGrid 3.8 0.2。
Velocity处理后的 statusSelect 如下所示:

I am using jqGrid 3.8.2. The statusSelect after Velocity has processed it looks like this:

function statusSelect(){
     return ":All;status1:status1;status2:status2";
}

我认为自从网格以前工作以来JSON数据传输没有问题在IE8中没有 setGridHeight loadComplete 处理程序。我还做了一些小修改,我只能部分重新计算(即禁用列调整大小)。
出于测试目的,这里是一个JSON对象:

I think there is no problem with the JSON data transfer since the grid previously worked in IE8 when there was no setGridHeight, loadComplete handler. I have also done some minor modifications which I can only partially recount (i.e. column resize disabled). For testing purposes here is a JSON object:

    {
    "page":"1",
    "records":2,
    "rows":[{"id":150,"cell":[150,false,"status1","columnData4","columndata5","columndata6","columndata7","Test1\u003cbr/\u003e\u003cspan style\u003d\u0027float:right;\u0027\u003e10.12.2010\u003c/span\u003e","columnData"]},
      {"id":157,"cell":[157,false,"status2","columnData41","columndata51","columnData61","columnData71","Test2\u003cbr/\u003e\u003cspan style\u003d\u0027float:right;\u0027\u003e22.12.2010\u003c/span\u003e","columnData"]}],
    "total":50.0
    }

我不知道如何使用total参数,所以我只声明了一个任意值(50D)。
inDetail函数只提交表单(我在这里使用Apache Turbine参数):

I don't know how to use the total parameter, so I just declared an arbitrary value (50D). The inDetail function just submits the form (I am using Apache Turbine parameter here):

    function inDetail(){
        document.forms['myForm'].eventSubmit_doAction.value = 'doSomeAction';
        document.forms['myForm'].submit();
    }


推荐答案

我无法重现问题你描述的。如何在这里看到网格可以在IE中加载而没有任何问题。由于缺少CSS,它看起来不太好,但一般都可以。所以我想你在这里没有发布的代码中存在问题。我建议您在 http://validator.w3.org/ 中验证您的HTML页面,您的测试JSON结果在 http://www.jsonlint.com/ http://www.jslint.com/

I could not reproduce the problem which you describe. How you can see here the grid can be loaded without any problem in IE. It looks not fine because of missing CSSs, but all works in general. So I suppose you have problem in the code which you not publish here. I recommend you to verify your HTML page in http://validator.w3.org/, your test JSON results in http://www.jsonlint.com/ and JavaScript code in http://www.jslint.com/.

我不会建议你在函数内使用 radio 变量,名称为 radio 。最好选择其他名称。最好添加10作为 parseInt 函数的第二个参数。在我的测试中,您的原始代码也没有相应的代码更改。

I would only not recommend you to use radio variable inside of the function with the same name radio. Better to choose another name. It is better also to add 10 as the second parameter of the parseInt function. In my tests your original code worked also without the corresponding code changes.

这篇关于IE8中可能存在jQuery / jqGrid问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆