easyui datagrid 初始化排序按钮不显示的问题

说明:

使用easyui datagrid时,如果需要设置某一列点击可排序,即sortable属性,datagrid初始化加载时,排序按钮会不显示,这样用户则不知道哪列可排。下面代码解决这个问题。

情况一:仍使用easyui原有图片

步骤一:找到easyui引用文件的源码,如下文件。

184901_iI3V_2829989.png

步骤二:修改源码:搜索“datagrid-sort-icon”,添加如下红框内的代码,即
else if(col.sortable == true){

    cell.addClass("datagrid-sort");

}

185408_CJ28_2829989.png

步骤三:修改页面中的css样式
.datagrid-sort .datagrid-sort-icon {
     padding: 0 13px 0 0;
     margin-left:4px;
     background: url('../easyui/themes/default/images/datagrid_icons.png') no-repeat -16px center;
 }
.datagrid-sort-desc .datagrid-sort-icon {
    padding: 0 13px 0 0;
    background: url('../easyui/themes/default/images/datagrid_icons.png') no-repeat -16px center;
}
.datagrid-sort-asc .datagrid-sort-icon {
    padding: 0 13px 0 0;
    background: url('../easyui/themes/default/images/datagrid_icons.png') no-repeat 0px center;
}

 

完成效果图:

190153_iF76_2829989.png

情况二:使用自定义图片

仅步骤三不同:需提前准备按钮图片sorter.png

.datagrid-sort .datagrid-sort-icon {
  padding: 0 13px 0 0;
  margin-left:4px;
  background: url(‘images/sorter.png‘) no-repeat 0px center;
}
.datagrid-sort-asc .datagrid-sort-icon,.datagrid-sort-desc .datagrid-sort-icon {
  margin-left:0px;
}

 

转载于:https://my.oschina.net/jingyao/blog/820176

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值