0

我试图让这个Excel 像在 Internet Explorer 8 中工作的 jqgrid 中的过滤一样。它在 Chrome 中工作正常,但在 Internet Explorer 中,行以某种方式被代码过滤掉了。如果我不使用 JSon 数据并从 oleg 示例复制本地数据似乎一切正常......我的目标浏览器是 IE 8,需要使用 JSon 数据并且正在使用 JQgrid 4.4.1 和多选 1.13.6 . 非常感谢您的帮助:-)

更新 几次刷新后,它有时可以在 IE 中运行。它与JSon数据加载时间有关吗?

<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.1/js/jquery.jqGrid.src.js"></script>

<script type="text/javascript">

    var scannamenlijst = '@ViewBag.scannamenlijst';

    //<![CDATA[
    /*global $ */
    /*jslint unparam: true, plusplus: true, browser: true */
    $(function () {

            $grid = $("#list"),
            myDefaultSearch = "cn",
            getColumnIndexByName = function (columnName) {
                var cm = $(this).jqGrid('getGridParam', 'colModel'), i, l = cm.length;
                for (i = 0; i < l; i += 1) {
                    if (cm[i].name === columnName) {
                        return i; // return the index
                    }
                }
                return -1;
            },
            modifySearchingFilter = function (separator) {
                var i, l, rules, rule, parts, j, group, str, iCol, cmi, cm = this.p.colModel,
                    filters = $.parseJSON(this.p.postData.filters);
                if (filters && filters.rules !== undefined && filters.rules.length > 0) {
                    rules = filters.rules;
                    for (i = 0; i < rules.length; i++) {
                        rule = rules[i];
                        iCol = getColumnIndexByName.call(this, rule.field);
                        cmi = cm[iCol];
                        if (iCol >= 0 &&
                                ((cmi.searchoptions === undefined || cmi.searchoptions.sopt === undefined)
                                    && (rule.op === myDefaultSearch)) ||
                                (typeof (cmi.searchoptions) === "object" &&
                                    $.isArray(cmi.searchoptions.sopt) &&
                                    cmi.searchoptions.sopt[0] === rule.op)) {
                            // make modifications only for the 'contains' operation
                            parts = rule.data.split(separator);
                            if (parts.length > 1) {
                                if (filters.groups === undefined) {
                                    filters.groups = [];
                                }
                                group = {
                                    groupOp: 'OR',
                                    groups: [],
                                    rules: []
                                };
                                filters.groups.push(group);
                                for (j = 0, l = parts.length; j < l; j++) {
                                    str = parts[j];
                                    if (str) {
                                        // skip empty '', which exist in case of two separaters of once
                                        group.rules.push({
                                            data: parts[j],
                                            op: rule.op,
                                            field: rule.field
                                        });
                                    }
                                }
                                rules.splice(i, 1);
                                i--; // to skip i++
                            }
                        }
                    }
                    this.p.postData.filters = JSON.stringify(filters);
                }
            },
            dataInitMultiselect = function (elem) {
                setTimeout(function () {
                    var $elem = $(elem), id = elem.id,
                        inToolbar = typeof id === "string" && id.substr(0, 3) === "gs_",
                        options = {
                            selectedList: 2,
                            height: "auto",
                            checkAllText: "all",
                            uncheckAllText: "no",
                            noneSelectedText: "Any",
                            open: function () {
                                var $menu = $(".ui-multiselect-menu:visible");
                                $menu.width("auto");
                                return;
                            }
                        },
                        $options = $elem.find("option");
                    if ($options.length > 0 && $options[0].selected) {
                        $options[0].selected = false; // unselect the first selected option
                    }
                    if (inToolbar) {
                        options.minWidth = 'auto';
                    }
                    $elem.multiselect(options);
                    $elem.siblings('button.ui-multiselect').css({
                        width: inToolbar ? "98%" : "100%",
                        marginTop: "1px",
                        marginBottom: "1px",
                        paddingTop: "3px"
                    });
                }, 50);
            };

        $grid.jqGrid({
            url: '/Stakeholder/getscanresponses/',
            mtype: 'POST',
            datatype: "json",
            jsonReader: {
                root: "rows", //array containing actual data
                page: "page", //current page
                total: "total", //total pages for the query
                records: "records", //total number of records
                repeatitems: false,
                //id: "initiatiefid" //index of the column with the PK in it
            },

            colNames: ['Initiatief', 'Respondent', 'Scan', 'Datum'],
            colModel: [
                //{name:'id',index:'id',width:70,align:'center',sorttype: 'int'},
                { name: 'initiatiefnaam', index: 'initiatiefnaam', width: 165 },
                { name: 'respondentnaam', index: 'respondentnaam', width: 165 },
                {
                    name: 'scannaam',  width: 200, align: 'center', formatter: 'select',
                    edittype: 'select',
                    editoptions: {
                        value: scannamenlijst,
                        //defaultValue: 'Intime',
                        multiple: true
                    },
                    stype: 'select',
                    searchoptions: {
                        sopt: ['eq', 'ne'],
                        value: scannamenlijst,
                        attr: { multiple: 'multiple', size: 4 },
                        dataInit: dataInitMultiselect
                    }
                },
                { name: 'responsedatum', index: 'responsedatum', width: 165, formatter: 'date', formatoptions: { srcformat: 'ISO8601Long', newformat: 'd/m/Y H:i:s' }, sorttype: 'date' }
            ],


            rowNum: 20,
            rowList: [5, 10, 20],
            pager: '#pager',
            loadonce: true,
            gridview: true,
            ignoreCase: true,
            rownumbers: true,
            sortname: 'responsedatum',
            viewrecords: true,
            sortorder: 'desc',
            caption: "Scanrespondenten",
            height: '100%',
            beforeRequest: function () {
                modifySearchingFilter.call(this, ',');
            }
        });
        $grid.jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: false }, {}, {}, {}, {
            multipleSearch: true,
            multipleGroup: true,
            recreateFilter: true
        });
        $grid.jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: myDefaultSearch });
    });
    //]]>
</script>
4

1 回答 1

0

找到了解决方案...愚蠢的错误我使用 mtype: 'POST' 而不是 mtype:'GET'

于 2013-05-29T11:14:31.117 回答