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 ...
随机推荐
- JavaScript高级编程———基本包装类型String和单体内置对象Math
JavaScript高级编程———基本包装类型和单体内置对象 <script> var stringObject = new String("hello world") ...
- idea 快捷键总结
IntelliJ Idea 常用快捷键列表 Ctrl+Shift + Enter,语句完成“!”,否定完成,输入表达式时按 “!”键Ctrl+E,最近的文件Ctrl+Shift+E,最近更改的文件Sh ...
- vscode sync插件 在不同设备 同步的坑
sync的好处不言而喻,在不同的设备都可以同步自己的插件和所有配置: 但是有时有总是会有坑, 现在把我遇到的坑记录下来,以防再次踩坑 VSCode 同步方案 VSCode 的插件 Setting Sy ...
- Mac 上用 Homebrew 安装 .NET Core 1.0 RC4 004771
年级大了,其实并不是很喜欢升级到最新版,特别是不怎么爱用还没有 Release 的版本了.虽然 .NET Core 已经是 RC4,但毕竟还没有 Release.可过年回来,用 yeoman 创建了一 ...
- readlink 命令
在Linux中readlink命令的作用是:输出符号链接值或权威文件名(通常使用的是-f参数) 格式:readlink [选项]... 文件 参数: -f, --canonicalize 递归跟随 ...
- Python Python-MySQLdb中的DictCursor使用方法简介
Python-MySQLdb中的DictCursor使用方法简介 by:授客 QQ:1033553122 DictCursor的这个功能是继承于CursorDictRowsMixIn,这个Mi ...
- Linux 配置iso系统盘为本地yum源
Linux配置iso系统盘为本地yum源 by:授客 QQ:1033553122 1.目的 安装软件时,经常会遇到包或类库的依赖性问题,为此,我们可以通过yum命令安装软件,尽量避免出现繁琐的软件 ...
- 表id关联数据获取至页面,制作下拉框多选进行数据多项获取(字段处理)
这周完成了一张表单,重点碰到以下问题: 1.freemaker获取年份的type值取year,类型直接为Long,传至后台和获取数据不需要转换: 2.freemaker获取日期type值为date, ...
- Python Word2Vec使用训练好的模型生成词向量
# 文本文件必须是utf-8无bom格式 from gensim.models.deprecated.word2vec import Word2Vec model = Word2Vec.load( ' ...
- 双启动:安装Windows 7 和 CentOS 7 双系统教程
笔记本配置:8G内存,200G SSD,先在virbox中成功安装双系统,能正常进入并使用 Windows 7 和 CentOS 7. 网上看到一大堆的安装 wingrub easyBCD,折腾了一 ...