本文介绍了如何在jqgrid中显示水平滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很宽的jqgrid,我通过width属性将其缩小了.当我使用它时,没有水平滚动条出现.如何显示?

I have a wide jqgrid that I have narrowed by mean of the width property. When I used that, no horizontal scroll bar appears. How can I show it?

任何帮助将不胜感激,

谢谢

Jaime

这是我当前拥有的JS代码.滚动条仍未显示:

This is the current JS code I have. Scrollbar is still not shown:

<script type="text/javascript">
$(function () {
    $("#personal").jqGrid({
        url: "@Url.Action("List")",
        datatype: "json",
        mtype: "GET",
        colNames: ["Departamento",
                   "Nombres",
                   "Apellido Paterno",
                   "Apellido Materno",
                   "RUT",
                   "Contraseña",
                   "Fecha Nacimiento",
                   "Fotografía",
                   "Estado Civil",
                   "Género",
                   "Dirección",
                   "Cargo",
                   "E-mail",
                   "Fecha Ingreso",
                   "Creación",
                   "Modificación",
                   " "],
        colModel: [
            { name: "departamento", index: "dep_nombre", editable: true, edittype: "select", editoptions: { width: 100, dataUrl: "@Url.Action("GetDepartments","Departamento")" }, width: 250, editrules: { required: true } },
            { name: "per_nombres", index: "per_nombres", editable: true, width: 250, editoptions: { maxlength: 80, size: 32 }, editrules:{ required:true } },
            { name: "per_apellido_paterno", index: "per_apellido_paterno", editable: true, width: 250, editoptions: { maxlength: 80, size: 32 }, editrules: { required: true } },
            { name: "per_apellido_materno", index: "per_apellido_materno", editable: true, width: 250, editoptions: { maxlength: 80, size: 32 } },
            { name: "per_dni", index: "per_dni", editable: true, width: 100, editoptions: { maxlength: 20, size: 17 }, editrules: { required: true } },
            { name: "per_contrasena", editable: true, width: 100, editoptions: { maxlength: 50, size: 17 }, editrules: { required: false } },
            { name: "per_fecha_nacimiento", index: "per_fecha_nacimiento", editable: true, width: 100, editrules: { date: true }, formatter: 'date', formatoptions: {srcformat: 'SortableDateTime', newformat: 'd-m-Y'}, editoptions: { size: 17, dataInit: function (el) { $(el).datepicker({ dateFormat: 'dd-mm-yy' }); } }, },
            { name: "per_fotografia", index: "per_fotografia", editable: true, width: 250, edittype: "file", editoptions: { maxlength: 255, size: 32 } },
            { name: "per_estado_civil", index: "per_estado_civil", editable: true, edittype: "select", editoptions: { value: "S:Soltero; C:Casado; V:Viudo; D:Divorciado" }, width: 100 },
            { name: "per_sexo", index: "per_sexo", editable: true, edittype: "select", editoptions: { value: "M:Masculino; F:Femenino" }, width: 100 },
            { name: "per_direccion", index: "per_direccion", editable: true, width: 250, editoptions: { maxlength: 512, size: 32 } },
            { name: "per_cargo", index: "per_cargo", editable: true, width: 100, editoptions: { maxlength: 50, size: 32 } },
            { name: "per_email", index: "per_email", editable: true, width: 100, editoptions: { maxlength: 80, size: 32 }, editrules: { email: true } },
            { name: "per_fecha_ingreso", index: "per_fecha_ingreso", editable: true, width: 100, editrules: { date: true }, formatter: 'date', formatoptions: {srcformat: 'SortableDateTime', newformat: 'd-m-Y'}, editoptions: { size: 17, dataInit: function (el) { $(el).datepicker({ dateFormat: 'dd-mm-yy' }); } }, },
            { name: "per_creado_el", index: "per_creado_el", editable:false, search:false, width: 100, align: "center", formatter: "date" },
            { name: "per_modificado_el", index: "per_modificado_el", editable:false, search:false, width: 100, align: "center", formatter: "date" },
            { name: 'acciones', width: 58, fixed: true, sortable: false, resize: false, search:false, formatter: 'actions', formatoptions: { keys: true } }
        ],
        jsonReader: {
            repeatitems: false,
            id: "per_id"
        },
        pager: "#pager",
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "per_apellido_paterno",
        sortorder: "asc",
        viewrecords: true,
        gridview: true,
        autoencode: true,
        multiselect: true,
        shrinkToFit: false,
        caption: "Funcionarios",
        editurl: "@Url.Action("AjaxEdit")",
        height: '100%',
        width: 935,
        rownumbers: true,
        rownumWidth: 40
    });

    $("#personal").jqGrid('hideCol', ["per_contrasena", "per_fotografia", "per_direccion"]);
    $("#personal").jqGrid('navGrid', '#pager', { edit: false, add: true, del: true, search: false }, { width: 500 }, { width: 500 }, {}, { multipleSearch: false, multipleGroup: false });
    $("#personal").jqGrid('filterToolbar', { searchOperators: false });

    $.jgrid.edit.addCaption = "Agregar Funcionario o Visita";
    $.jgrid.edit.editCaption = "Modificar Funcionario o Visita";
    $.jgrid.edit.saveData = "¡El funcionario fue modificado! ¿Almacena los cambios?";

    $.jgrid.formatter.date.newformat = 'd-m-Y H:i';
});
</script>

推荐答案

没有任何代码,您需要查看一些内容...

Without any code, some things you'll need to look at...

请勿使用autowidth,并确保您未使用shrinkToFit(需要将其设置为false).除此之外,水平滚动条应仅显示这两个更改.除此之外,还应确保为列模型中的每个列显式设置宽度.

Do not use autowidth and make sure you are not using shrinkToFit (it needs to be set to false). Other than that, the horizontal scrollbar should appear with just those two changes. In addition to this, you should also make sure you set the width explicitly for each column within the column model.

这篇关于如何在jqgrid中显示水平滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 07:13