1

我有一个不错的 jqgrid 和 columnchooser。但是当我使用 columnchooser 删除所有列时,我的 JQGrid 表消失了。(width:0) 那么有没有可能有最小宽度和最大宽度?
提前致谢。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<link href="../../Scripts/plugins/ui.multiselect.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-ui-1.8.23.min.js" type="text/javascript"></script>
<script src="../../Scripts/plugins/ui.multiselect.js" type="text/javascript"></script>
<script src="../../Scripts/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="../../Scripts/src/i18n/grid.locale-nl.js" type="text/javascript"></script>
<link href="../../Scripts/css/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />

<table id="list"></table>
<div id="pager"></div>

<script type="text/javascript">
jQuery(document).ready(function () {
    jQuery("#list").jqGrid({
        url: '/Home/GridData/',
        datatype: 'json',
        mtype: 'GET',
        autowidth: true,
        colNames: ['Budgetsleutel', 'Beleidsdomein', 'beleidsitem'],
        colModel: [
      { name: 'budetsleutel', index: 'budetsleutel', width: 40, align: 'left', sortable: true, resizable: true, search: true },
      { name: 'beleiddsdomein', index: 'beleidsdomein', width: 40, align: 'left', sortable: true, resizable: true, search: true },
      { name: 'beleidsitem', index: 'beleidsitem', width: 200, align: 'left', sortable: true, resizable: true, search: true}],
        pager: '#pager',
        pgbuttons: true,
        rowNum: 10,
        rowList: [],
        sortname: 'Id',
        sortorder: "desc",
        gridview: true,
        viewrecords: true,
        height: 100,
        caption: "Toolbar Searching"
    });
    jQuery("#list").jqGrid('navGrid', '#pager');
    jQuery("#list").jqGrid('navButtonAdd', '#pager', {
        caption: "Columns",
        buttonicon: "ui-icon-calculator",
        title: "choose columns",
        jqModel:true,
        onClickButton: function () {
            jQuery("#list").jqGrid('columnChooser');
        }
    });
});

4

1 回答 1

1

我在 jqgrid 的 wiki 页面中找到了我的问题的解决方案。
见下面的代码:

        onClickButton: function () {
            jQuery("#list").jqGrid('columnChooser', {
                done: function (perm) {
                    if (perm) {
                        this.jqGrid("remapColumns", perm, true);
                        this.jqGrid("setGridWidth", $("#gridwrapper").width());
                    } 
                }
            });
        }
于 2012-09-23T10:37:56.913 回答