jqgrid 在表格底部添加自定义按钮
往往我们需要在jqgrid底部的分页行中添加一些自定义按钮,效果如下:

上图中,三个按钮均是自定义添加上的。
1、要新增自定义按钮在表格底部,仍离不开分页div,需要给jqgrid绑定分页方法
2、由于此功能中,我们不使用jqgrid默认按钮,故需要将默认按钮设置为不启用false
以上截图完整代码,参考如下:
//根据传入的筛选信息加载grid
function LoadFilterGrid(newFilterArr) {
$.jgrid.gridUnload("filterGrid");//先卸载 $("#filterGrid").jqGrid({
altRows: true,//隔行换色
data: newFilterArr,
editurl: 'clientArray',
styleUI: 'Bootstrap',
//responsive: true,
datatype: "local",
page: 1,
colModel: [
{ label: 'ID', name: 'Id', width: 20, hidden: true },//id值隐藏
{ label: 'TbReportId', name: 'TbReportId', width: 20, hidden: true },//TbReportId值隐藏
{ label: '字段编码', name: 'FieldCode', width: 150, editable: false },
{//参数名作为主键
label: '参数名',
name: 'FieldParam',
width: 150,
key: true,
editable: true,
edittype: "text"
//editrules: { required: true }
},
{
label: '显示名称',
name: 'FieldName',
width: 150,
editable: true,
edittype: "text"
//editrules: { required: true }
},
{
label: '是否筛选',
name: 'IsSearch',
width: 80,
editable: true,
edittype: "select",
editoptions: {
value: "false:否;true:是"
}//默认为否
},
{
label: '字段类型',
name: 'DataType',
width: 90,
editable: true,
edittype: "select",
editoptions: {
value: "Decimal:数值型;String:字符串;Int32:整型;Int64:长整型;Int16:短整型;DateTime:时间"
}
}, {
label: '正则表达式',
name: 'RegularId',
width: 120,
editable: true,
edittype: "select",
editoptions: {
value: GetRegulars
}
},
{
label: '默认值',
name: 'DefaultValue',
width: 80,
editable: true,
edittype: "text"
},
{
label: '筛选类型',
name: 'FilterType',
width: 140,
editable: true,
edittype: "select",
editoptions: {
value: "1:文本框;2:复选下拉框;3:单选下拉框;4:日期/年月日;5:日期/年月"
}
},
{
label: '下拉筛选sql',
name: 'FilterSql',
width: 130,
editable: true,
edittype: "textarea"
},
{
label: '筛选排序',
name: 'OrderNum',
width: 80,
editable: true,
edittype: "text"
},
{
label: '快捷筛选',
name: 'IsQuick',
width: 80,
editable: true,
edittype: "select",
editoptions: {
value: "false:否;true:是"
}//默认非快捷筛选
},
{
label: '内置字段?',
name: 'IsCustom',
width: 100,
editable: false
},
{
label: '筛选说明',
name: 'Remark',
width: 120,
editable: true,
edittype: "textarea",
//edittype: "text",
hidden: true,//隐藏字段
editrules: { edithidden: true }//让隐藏字段可编辑,编辑时显示
}
],
loadonce: false,
viewrecords: true,
shrinkToFit: false,
autoScroll: false,
height: window.innerHeight * 0.6,
width: $(".modal-body").width(),
// autowidth: true,
rowNum: newFilterArr.length + 3,//默认比原行数+3
pager: "#filterGridPager"
}); $('#filterGrid').navGrid('#filterGridPager',
{ edit: false, add: false, del: false, search: false, refresh: false, view: false, position: "left", cloneToTop: false }); // 添加一个‘添加’按钮
$('#filterGrid').navButtonAdd('#filterGridPager',
{
buttonicon: "glyphicon glyphicon-plus",
title: "添加",
caption: "添加",
position: "last",
onClickButton: addRow
}); //添加一个‘删除’按钮
$('#filterGrid').navButtonAdd('#filterGridPager',
{
buttonicon: "glyphicon glyphicon-trash",
title: "删除",
caption: "删除",
position: "last",
onClickButton: delRow
}); //添加一个‘刷新’按钮
$('#filterGrid').navButtonAdd('#filterGridPager',
{
buttonicon: "glyphicon glyphicon-refresh",
title: "刷新",
caption: "刷新",
position: "last",
onClickButton: refreshFiterGrid
}); //加载完毕后,打开所有行的编辑
startEdit($("#filterGrid"));
}
说明:
1)filterGrid为jqgrid所在的table,filterGridPager为jqgrid分页插件所在的div
2)给filterGrid绑定分页行filterGridPager,将jqgrid默认按钮禁用(黄色区域)。
$('#filterGrid').navGrid('#filterGridPager',{ edit: false, add: false, del: false, search: false, refresh: false, view: false, position: "left", cloneToTop: false })
若不添加以上行代码,将不会显示自定义的按钮,看截图:

3)通过navButtonAdd添加自定义按钮方法
// 添加一个‘添加’按钮
$('#filterGrid').navButtonAdd('#filterGridPager',
{
buttonicon: "glyphicon glyphicon-plus",
title: "添加",
caption: "添加",
position: "last",
onClickButton: addRow
});
4)小提示:由于当前功能中,会多次进行jqgrid表格编辑操作(添加、删除、编辑行),会多次绑定表格数据。为确保数据成功刷新与展示在每次绑定jqgrid时先卸载表格
$.jgrid.gridUnload("filterGrid");//先卸载
5)给按钮设置样式。buttonicon: "glyphicon glyphicon-plus"
jqgrid 在表格底部添加自定义按钮的更多相关文章
- AppBoxPro - 细粒度通用权限管理框架(可控制表格行内按钮)源码提供下载
特别声明: 提供的源代码已经包含了 AppBoxPro 的全部源代码,用 VS2012 打开项目后,直接 Ctrl+F5 可以运行起来(默认使用VS自带的LocalDB数据库). FineUIPro是 ...
- 给angularJs grid列上添加自定义按钮
由于项目需要在angular 显示的表格中添加按钮,多次查询资料终于找到解决方法.就是给columnDefs 上的列增加 cellTemplate,同时绑定对应的触发事件,代码如下 columnDef ...
- Dynamics CRM2013 任务列表添加自定义按钮
任务列表的command bar 上面添加自定义按钮如下 要注意的是此处的列表不是任务实体而是活动实体,如果你是在任务实体的home栏上面加那你永远看不见按钮的显示,但如果是要在任务的表单界面上加按钮 ...
- Dynamics 365 CRM 添加自定义按钮
在添加自定义按钮之前,我们需要下载这个工具 RibbonWorkbench, 它是专门针对自定义命令栏和Ribbon区域. 下载之后是一个zip压缩包. 怎样安装RibbonWorkbench: Se ...
- ckeditor添加自定义按钮整合swfupload实现批量上传图片
ckeditor添加自定义按钮整合swfupload实现批量上传图片给ckeditor添加自定义按钮,由于ckeditor只能上传一张图片,如果要上传多张图片就要结合ckfinder,而ckfinde ...
- RN如何固定底部的按钮
如上图的底部新增按钮,要是放在web里那是相当简单,直接是用固定定位就行,但是在RN里是没有固定定位可言的. 方案一: 采用绝对定位,相对于最外层的定位在底部位置.(在部分安卓机上有问题,动态计算的高 ...
- jqGrid多级表格的实现
原博主链接:http://blog.csdn.net/dreamstar613/article/details/54616503 jqGrid多级表格(可N级) 主要用的方法: subGridRowE ...
- jqGrid添加自定义按钮
用法: <script> ... jQuery("#grid_id").navGrid("#pager",...).navButtonAdd(&qu ...
- 00001- layui 表格的默认工具栏添加自定义按钮
首先定义table: var tableIns = table.render({ elem:'#businessUserListTable' ,url: ctx+'/business/business ...
随机推荐
- Echarts地图绘制(散点,色卡)
echarts绘制地图时,提供了js内部注册,也提供了json数据手动注册,这两种都可以绘制对应地图,但有一点不同的是,js内部只注册了中国地图和世界地图,而json数据提供了世界,中国,中国城市的数 ...
- 二叉搜索树(Binary Search Tree)实现及测试
转:http://blog.csdn.net/a19881029/article/details/24379339 实现代码: Node.java //节点类public class Node{ ...
- Android性能优化系列之APK终极瘦身策略
第1条:使用一套资源 这是最基本的一条规则,但非常重要. 对于绝大对数APP来说,只需要取一套设计图就足够了.鉴于现在分辨率的趋势,建议取720p的资源,放到xhdpi目录. 相对于多套资源,只使用7 ...
- 基于纤程(Fiber)实现C++异步编程库(一):原理及示例
纤程(Fiber)和协程(coroutine)是差不多的概念,也叫做用户级线程或者轻线程之类的.Windows系统提供了一组API用户创建和使用纤程,本文中的库就是基于这组API实现的,所以无法跨平台 ...
- Python+Selenium笔记(十七):操作cookie
(一)方法 方法 简单说明 add_cookie(cookie_dict) 在当前会话中添加cookie信息 cookie_dict:字典,name和value是必须的 delete_all_cook ...
- Sql server在使用sp_executesql @sql执行文本sql时,报错: Could not find database ID 16, name '16'. The database may be offline. Wait a few minutes and try again.
最近在公司项目中使用exec sp_executesql @sql执行一段文本sql的时候老是报错: Could not find database ID 16, name '16'. The dat ...
- python自学——集合
#皇城根儿#集合:是无序的.不重复的:1.去重:2.关系测试#创建集合#创建数字集合number=set([1,3,5,7,9]) #数字型集合str_type=set(["im" ...
- Nlog.Config:日志方法步骤
首先添加negut包Nlog.Config: 安装完毕以后,可以替换Nlog.config <?xml version="1.0" encoding="utf-8& ...
- 高通LCD的pwm背光驱动
发生异常的现象: msm8953 lcd在快速亮灭的情况下背光概率性休眠不灭:测量高通pwm,发现正常的时候pwm的管脚LCM_BL_PWM为低电平,失败的时候为高电平: 根据原理图: mpp是什么? ...
- UNIX高级环境编程(16)文件系统 < 雨后 >
来点绿色放松一下眼睛吧 :) 文件系统是对文件和目录的组织集合. 一 设备文件 设备文件和系统的某个设备相对应. 设备驱动程序 处理设备的所有IO请求. 提供了一致的API接口,对应于系统调用的ope ...