2013-06-01 56 views
3

我有一個寬jqgrid,我已經通過width屬性縮小了範圍。當我使用它時,不會出現水平滾動條。我如何顯示它?如何在jqgrid中顯示水平滾動條

任何幫助,將不勝感激,

感謝

海梅

編輯:

這是當前的JS代碼我有。滾動條仍然未顯示:

<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> 

回答

6

無需任何代碼,有些事情你需要看看...

不要使用autowidth,並確保您使用的不是shrinkToFit(它需要設置爲false)。除此之外,水平滾動條應該只出現這兩個變化。除此之外,還應確保您爲列模型中的每個列顯式設置寬度。

3

添加一個具有一定寬度和溢出的div:圍繞表的自動操作應該能夠實現。

<div style="width:100px;overflow:auto;"><table id="personal"></table><div> 
0

也許你有一些其他的CSS在頁面上定義的問題。只使用你的代碼的The demo顯示水平滾動條。

1

最後是因爲沒有數據顯示在網格中。當網格返回數據時,出現水平滾動條。

問候, 海梅

2

只需添加

shrinkToFit : false, 

這讓表格的佈局固定成長爲每個單元尺寸沒有得到縮小爲每桌的母公司寬度/

2

的水平滾動條適用於以下條件:

  1. 設置參數shrinkToFitforceFit。例如:

    $('#gridObtenerRegistros').jqGrid({ shrinkToFit:false, forceFit:true,

    ,並且不使用寬度參數。

  2. colmodel內設置寬度屬性。例如:

    colModel:[ {name:'numEmpleadoCliente',index:'numEmpleadoCliente', width:80, sortable: false, resizable: false}, {name:'nombre',index:'nombre', width:215, sortable: false, resizable: false}, {name:'estatus',index:'estatus', width:50, sortable: false, resizable: false}],

  3. 檢查.ui-jqgrid .ui-jqgrid-bdiv類的樣式具有:`

    overflow: auto;

  4. 檢查柵格表不具有寬度屬性。

    在我的例子: <table id="gridBusquedaRegistros"></table>

希望這有助於任何人。