JQGrid标题未对齐

时间:2016-08-18 07:52:46

标签: jquery html css jqgrid

我正在使用4.4.4 - jQuery Grid<= jquery 1.8.2,以及我如何制作我的jqgrid

    function FAGrid() {
    var url1 = 'URL';
    $("#FAList").jqGrid({
        url: url1,
        datatype: 'json',
        mtype: 'POST',
        colNames: ['rowId', 'FAID', 'Employee', 'Date<br/> Filed', 'Duration', 'Shift', 'ProjectSite', 'Contact Person', 'Purpose', 'Requested By', 'Approved By', 'Date Approved'],
        colModel: [
                    { name: 'rowId', index: 'rowId', hidden: true, width: 20 },
                    { name: 'FAID', index: 'FAID', hidden: true, editable: true, sortable: false, width: 20, align: 'center' },
                    { name: 'CompleteName', index: 'CompleteName', hidden: false, editable: true, sortable: false, width: 160, align: 'center' },
                    { name: 'FADateFiled', index: 'FADateFiled', hidden: false, editable: true, sortable: false, width: 52, align: 'center' },
                    { name: 'Duration', index: 'Duration', hidden: false, editable: true, sortable: false, width: 97, align: 'center' },
                    { name: 'ShiftDesc', index: 'ShiftDesc', editable: true, hidde: false, width: 75, align: 'center' },
                    { name: 'ProjectSite', index: 'ProjectSite', editable: true, sortable: false, width: 75, align: 'center' },
                    { name: 'FAContactPerson', index: 'FAContactPerson', editable: true, hidde: false, width: 75, align: 'center' },
                    { name: 'Purpose', index: 'Purpose', editable: true, sortable: false, width: 75, align: 'center' },
                    { name: 'FARequestedBy', index: 'FARequestedBy', editable: true, sortable: false, width: 115, align: 'center' },
                    { name: 'FAApprovedBy', index: 'FAApprovedBy', editable: true, sortable: false, width: 115, align: 'center' },
                     { name: 'FADateApproved', index: 'FADateApproved', editable: true, sortable: false, width: 75, align: 'center' }
                  ],
        pager: $('#FAPager'),
        rowNum: 5,
        rowList: [5, 10, 20],
        sortname: 'FADateFiled',
        sortorder: 'desc',
        viewrecords: true,
        imgpath: '/Content/themes/redmond/images/',
        height: '100%',
        loadComplete: function () {
            var ids = jQuery("#FAList").getDataIDs();
            var len = ids.length,
                newLine;
            if (len < 5) {
                AddNewRowToGrid(len, "#FAList");
            }
         }
    });
}

这是图像。即使我改变名称或任何模型的宽度,它仍然是不对齐的。问题是什么?。 CSS? jqGrid的?还是?

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试为colModel中的项目提供属性fixed: true

答案 1 :(得分:0)

我通过添加一些值创建了一个本地样本。在我的情况下它工作正常。实际上你想在loadComplete做什么?我已经评论了loadComplete函数。

以下是我的代码。

<强> HTML

<table id="FAList"></table>
<div id="FAPager"></div>

<强> JS

$(document).ready(function() {

var data = [
{ rowId: "1",   FAID: "2",  CompleteName: "Emp name",   FADateFiled: "08/18/2016",  Duration: "3",  ShiftDesc: "Desc",  ProjectSite: "Site",    FAContactPerson: "Contact Person",  Purpose: "Purpose", FARequestedBy: "Requester", FAApprovedBy: "Approver",   FADateApproved: "08/18/2016"
},
{ rowId: "1",   FAID: "2",  CompleteName: "Emp name1",  FADateFiled: "08/18/2016",  Duration: "3",  ShiftDesc: "Desc1", ProjectSite: "Site1",   FAContactPerson: "Contact Person1", Purpose: "Purpose1",    FARequestedBy: "Requester1",    FAApprovedBy: "Approver1",  FADateApproved: "08/18/2016"
} 
];

function FAGrid() {

    var url1 = 'URL';
    $("#FAList").jqGrid({
        //url: url1,
        //datatype: 'json',
        datatype: 'local',
        //mtype: 'POST',
        colNames: ['rowId', 'FAID', 'Employee', 'Date<br/> Filed', 'Duration', 'Shift', 'ProjectSite', 'Contact Person', 'Purpose', 'Requested By', 'Approved By', 'Date Approved'],
        colModel: [
                    { name: 'rowId', index: 'rowId', hidden: true, width: 20 },
                    { name: 'FAID', index: 'FAID', hidden: true, editable: true, sortable: false, width: 20, align: 'center' },
                    { name: 'CompleteName', index: 'CompleteName', hidden: false, editable: true, sortable: false, width: 160, align: 'center' },
                    { name: 'FADateFiled', index: 'FADateFiled', hidden: false, editable: true, sortable: false, width: 52, align: 'center' },
                    { name: 'Duration', index: 'Duration', hidden: false, editable: true, sortable: false, width: 97, align: 'center' },
                    { name: 'ShiftDesc', index: 'ShiftDesc', editable: true, hidde: false, width: 75, align: 'center' },
                    { name: 'ProjectSite', index: 'ProjectSite', editable: true, sortable: false, width: 75, align: 'center' },
                    { name: 'FAContactPerson', index: 'FAContactPerson', editable: true, hidde: false, width: 75, align: 'center' },
                    { name: 'Purpose', index: 'Purpose', editable: true, sortable: false, width: 75, align: 'center' },
                    { name: 'FARequestedBy', index: 'FARequestedBy', editable: true, sortable: false, width: 115, align: 'center' },
                    { name: 'FAApprovedBy', index: 'FAApprovedBy', editable: true, sortable: false, width: 115, align: 'center' },
                     { name: 'FADateApproved', index: 'FADateApproved', editable: true, sortable: false, width: 75, align: 'center' }
                  ],
        pager: $('#FAPager'),
        rowNum: 5,
        rowList: [5, 10, 20],
        sortname: 'FADateFiled',
        sortorder: 'desc',
        viewrecords: true,
        //imgpath: '/Content/themes/redmond/images/',
        height: '100%',
        /*loadComplete: function () {
           debugger;
           var ids = jQuery("#FAList").getDataIDs();
           var len = ids.length,
           newLine;
           //if (len < 5) {
           //    AddNewRowToGrid(len, "#FAList");
           //}
        }*/
    });
    $("#FAList")[0].addJSONData({
            total: 1,
            page: 1,
            records: data.length,
            rows: data
        });    

    }

    FAGrid();

 });

请查看此Fiddle以获取参考