jqGrid: how to change cell padding

前端 未结 6 1556
梦谈多话
梦谈多话 2021-02-09 08:31

I\'m using jqGrid3.6.5 on google hosted jQueryUI1.8.2 and jQuery1.4.2

I want to change the cell padding of a jqGrid. For testing purposes I want to set it to 10px all ar

6条回答
  •  梦如初夏
    2021-02-09 08:58

    Add a new CSS class to the columns that you need to style:

    $("#dataTable").jqGrid({
    
    ...
    
      colModel:[
        {name:"name",index:"name", width:600, align:"left", classes:"grid-col"},
        {name:"price",index:"price", width:100, align:"right", classes:"grid-col"}
      ],
    
    ...
    
    });
    

    Note classes:"grid-col" in this snippet.

    Then style the columns with CSS using !important to give these rules the highest priority:

    .grid-col {
      padding-right: 5px !important;
      padding-left: 5px !important;
    }
    

    It works for me in jqGrid 4.5.4 with no column resizing problems.

提交回复
热议问题