当前位置: 代码迷 >> Web前端 >> jqGrid 多字段查询在ie6、7中的有关问题
  详细解决方案

jqGrid 多字段查询在ie6、7中的有关问题

热度:762   发布时间:2012-11-22 00:16:41.0
jqGrid 多字段查询在ie6、7中的问题
jqGrid.searchFilters.js 红色部分存在问题。作者考虑到浏览器的问题却未给出处理方法,似乎有点偷懒。
jQ.find(".ui-add").click(function(e) {
                var row = jQuery(e.target).parents(".sf");
                var newRow = row.clone(true).insertAfter(row);
                newRow.find(".ui-state-default").removeClass("ui-state-hover ui-state-active");
                if (opts.clone) {
                    newRow.find("select[name='field']")[0].selectedIndex = row.find("select[name='field']")[0].selectedIndex;
                    var stupid_browser = (newRow.find("select[name='op']")[0] == null); // true for IE6
                    if (!stupid_browser)
                        newRow.find("select[name='op']").focus()[0].selectedIndex = row.find("select[name='op']")[0].selectedIndex;
                    var jElem = newRow.find("select.vdata");
                    if (jElem[0] != null) // select doesn't copy it's selected index when cloned
                        jElem[0].selectedIndex = row.find("select.vdata")[0].selectedIndex;
                } else {
                    newRow.find(".data input").val(""); // blank all input values
                    newRow.find("select[name='field']").focus();
                }
                if (opts.datepickerFix === true && jQuery.fn.datepicker !== undefined) { // using $.data to associate data with document elements is Not Good
                    row.find(".hasDatepicker").each(function() {
                        var settings = jQuery.data(this, "datepicker").settings;
                        newRow.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(settings);
                    });
                }
                newRow.find("select[name='field']").change();
                return false;
            });

将上面红色部分修改为:
        if (stupid_browser)
             newRow.find("select[class='default']").attr("name","op");    //为clone的操作符的select添加name属性


补充jquery.jqGrid.min.js文件修改方法:

查找if(b.find("select[name='op']")[0]!=null)

替换为if(b.find("select[name='op']")[0]==null)b.find("select[class='default']").attr("name", "op");