关于jquery:jqGrid无法正确显示

jqGrid not display properly

我正在使用jQuery网格插件jqGrid来显示数据数组。

我想要实现的是
1.默认情况下,该网格为空。
2.当用户单击搜索按钮时,它将使用AJAX加载数据
3.数据将加载到网格中。

从附件中,我出现此错误

  • 网格宽度不是100%px,而是两个小
  • 寻呼机未显示。如何使用方法来控制寻呼机?
  • 如何解决?有样品吗?

    谢谢

    screenshot

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    Search
    <form id="project_search_form">
    <table class="grid">
    ...
        <tr>        
            <td>search</td>
        </tr>
    </table>
    </form>


    <table id="projectList"></table>


    <script type="text/javascript">

    $(document).ready(function(){

        jQuery("#projectList").jqGrid({
            url:'server.php?q=2',
            datatype:"json",
            colNames:['ID','Name'],
            colModel:[ {name:'projectId',index:'id', width:55} , {name:'name',index:'name', width:55}],
            rowNum:10,
            rowList:[10,20,30],
            pager: '#pager5',
            sortname: 'id',
            viewrecords: true,
            sortorder:"desc",
            caption:"Simple data manipulation",
            editurl:"someurl.php" }).navGrid("#projectPager",{edit:false,add:false,del:false});
    });

    function searchProject(){
        var param =  $('#project_search_form').serialize();
         BaseAjaxUtil.object_search(param,
                  {
                     callback:function(data){                        
                         var jsongridRows = eval("("+data+")");

                         for(var i = 0; i < jsongridRows.length; i++) {
                            var datarow = jsongridRows[i];      
                            var su=jQuery("#projectList").jqGrid('addRowData',i+1, datarow);
                            // if(su) alert("Succes. Write custom code to add data in server"); else alert("Can not update");
                         }

                     },
                     errorHandler:function(errorString) { alert("error:"+errorString); }            
                    }
                  );        
    }


    您可以使用autowidth: true选项控制宽度。来自jqGrid文档:

    When set to true, the grid width is recalculated automatically to the width of the parent element. This is done only initially when the grid is created. In order to resize the grid when the parent element changes width you should apply custom code and use the setGridWidth method for this purpose

    然后,您只需要确保您的父元素具有适当的宽度即可。