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 ...
随机推荐
- BZOJ5289: [Hnoi2018]排列
传送门 第一步转化,令 \(q[p[i]]=i\),那么题目变成: 有一些 \(q[a[i]]<q[i]\) 的限制,\(q\) 必须为排列,求 \(max(\sum_{i=1}^{n}w[i] ...
- HTTP协议学习随笔
一 HTTP概述 HTTP简单说其实就是一套语言交流规则!Http使用的是可靠的数据传输协议,因此即使数据来自地球的另一端,也能够确保数据在传输过程中不会被损坏或产生混乱. B/S结构 用户在浏览器, ...
- JavaSE——线程同步
为什么需要线程同步? 同步就是协同步调,按预定的先后次序进行运行.如:你说完,我再说而并非一起动作.“同”字应是指协同.协助.互相配合. 如进程.线程同步,可理解为进程或线程A和B一块配合,A执行到一 ...
- Available to Promise (ATP) in SAP-SD
One short note before we start off the subject: Availability refers to the projections of future mat ...
- loadrunner 脚本开发- web_url函数详解
脚本开发- web_url函数详解 by:授客 QQ:1033553122 加载指定url的web页面(GET请求) C语言函数 int web_url( const char *StepName ...
- React Native - TextInput详细解说
1,TextInput组件介绍 TextInput 组件除了作为输入框实现基本的输入功能外,它还提供了许多其他功能,比如自动校验.占位符以及指定弹出不同的键盘类型等. 2,组件的属性 (1)autoC ...
- 基于docker搭建jumpserver堡垒机
一.环境信息 1.jumpserver 192.168.137.129 CentOS6.4 kernel版本为 3.10.5-3.el6.x86_64 2.客户机 dev01-04 3.docke ...
- 重学C语言---05运算符、表达式和语句
一.循环简介 实例程序 /*shoes1.c--把一双鞋的尺码变为英寸*/#include <stdio.h>#define ADJUST 7.64#define SCALE 0.325 ...
- LINQ学习:Select的用法
转载于:http://www.cnblogs.com/ForEvErNoME/archive/2012/07/25/2606659.html 说明:在查询表达式中,select 子句可以指定将在执行查 ...
- MySQL: Building the best INDEX for a given SELECT
Table of Contents The ProblemAlgorithmDigressionFirst, some examplesAlgorithm, Step 1 (WHERE "c ...