往往我们需要在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 在表格底部添加自定义按钮的更多相关文章

  1. AppBoxPro - 细粒度通用权限管理框架(可控制表格行内按钮)源码提供下载

    特别声明: 提供的源代码已经包含了 AppBoxPro 的全部源代码,用 VS2012 打开项目后,直接 Ctrl+F5 可以运行起来(默认使用VS自带的LocalDB数据库). FineUIPro是 ...

  2. 给angularJs grid列上添加自定义按钮

    由于项目需要在angular 显示的表格中添加按钮,多次查询资料终于找到解决方法.就是给columnDefs 上的列增加 cellTemplate,同时绑定对应的触发事件,代码如下 columnDef ...

  3. Dynamics CRM2013 任务列表添加自定义按钮

    任务列表的command bar 上面添加自定义按钮如下 要注意的是此处的列表不是任务实体而是活动实体,如果你是在任务实体的home栏上面加那你永远看不见按钮的显示,但如果是要在任务的表单界面上加按钮 ...

  4. Dynamics 365 CRM 添加自定义按钮

    在添加自定义按钮之前,我们需要下载这个工具 RibbonWorkbench, 它是专门针对自定义命令栏和Ribbon区域. 下载之后是一个zip压缩包. 怎样安装RibbonWorkbench: Se ...

  5. ckeditor添加自定义按钮整合swfupload实现批量上传图片

    ckeditor添加自定义按钮整合swfupload实现批量上传图片给ckeditor添加自定义按钮,由于ckeditor只能上传一张图片,如果要上传多张图片就要结合ckfinder,而ckfinde ...

  6. RN如何固定底部的按钮

    如上图的底部新增按钮,要是放在web里那是相当简单,直接是用固定定位就行,但是在RN里是没有固定定位可言的. 方案一: 采用绝对定位,相对于最外层的定位在底部位置.(在部分安卓机上有问题,动态计算的高 ...

  7. jqGrid多级表格的实现

    原博主链接:http://blog.csdn.net/dreamstar613/article/details/54616503 jqGrid多级表格(可N级) 主要用的方法: subGridRowE ...

  8. jqGrid添加自定义按钮

    用法: <script> ... jQuery("#grid_id").navGrid("#pager",...).navButtonAdd(&qu ...

  9. 00001- layui 表格的默认工具栏添加自定义按钮

    首先定义table: var tableIns = table.render({ elem:'#businessUserListTable' ,url: ctx+'/business/business ...

随机推荐

  1. python3获取一个网页特定内容

    我们今天要爬取的网址为:https://www.zhiliti.com.cn/html/luoji/list7_1.html 一.目标:获取下图红色部分内容 即获取所有的题目以及答案. 二.实现步骤. ...

  2. 回调地狱以及用promise怎么解决回调地狱

    哈哈哈,我又又又回来了,不好意思,最近枸杞喝的比较到位,精力比较旺盛. 现在我们来聊一聊啥是回调地狱,注意是回调地狱啊   不是RB人民最爱拍的那啥地狱啊,来吧,上车吧少年,这是去幼儿园的车 都让开, ...

  3. ArrayList初步

    使用ArrayList,需添加引用:using System.Collections: 第一个例子: ArrayList list = new ArrayList(); list.Add(" ...

  4. 安卓测试【三】adb简单命令及monkey使用

    Ⅰ 配置好android sdk环境变量之后,将android手机连接到电脑上,进行一些adb的简单命令的操作. adb,安卓调试桥,android   sdk的一个工具.直接操作管理安卓模拟器或者真 ...

  5. SecureCRT使用问题记录

    1.破解版下载&安装 参考:https://bbs.feng.com/read-htm-tid-6939481.html 2.session导入 查看 SecureCRT-Preference ...

  6. Hibernate 注释用法

    注释 到现在为止,你已经看到 Hibernate 如何使用 XML 映射文件来完成从 POJO 到数据库表的数据转换的,反之亦然.Hibernate 注释是无需使用 XML 文件来定义映射的最新方法. ...

  7. 在 Azure Resource Manager 中为虚拟机设置密钥保管库

    Note Azure 具有两种不同的部署模型,用于创建和处理资源:Resource Manager 模型和经典模型.本文介绍使用 Resource Manager 部署模型.Azure 建议对大多数新 ...

  8. 服务器重启可能会导致SQL Server中部分数据库变为single user mode

    今天检查公司生产服务器的SQL Server数据库,惊讶的发现有三个生产数据库变为了single user mode.奇怪的是没有任何人和程序执行过SQL语句将这三个数据库设置为single user ...

  9. commons-pool 解析

    首先抛出个常见的长连接问题: 1  都知道连接MySQL的应用中大多会使用框架例如 c3p0 ,dbcp proxool 等来管理数据库连接池. 数据库连接池毫无疑问都是采用长连接方式. 那么MySQ ...

  10. pip 设置国内源

    最近使用 pip 安装包,动辄十几 k 甚至几 k 的下载速度,确实让人安装的时候心情十分不好.所以还是要给 pip 换一个国内的源.可以显著的提升安装速度.有更多的时间来研究算法. 下面,列一下收集 ...