@songlaf
2017-11-26T14:07:55.000000Z
字数 1925
阅读 598
BhTalbe
完成查询之后,可以继续完成增删改啦
$("#bhTable").bhTable({
url:"listByPage",
height: 400,
width:1100,
columns: [
{name: 'id',title: "序号",width: 50,key: true, sotrable:true},
{name: 'code', title: "编码",width: 100,sotrable:true},
{name: 'name', title: "名称", width: 200, sotrable:true},
{name: 'categoryName', title: "类别", index: 'categoryName',sortField:'category_code',sotrable:true, width: 100},
{name: 'price', title: "单价",width: 50, sotrable:true},
{name: 'qty', title: "库存数量", width: 100, sotrable:true},
{name: 'description', title: "备注", width: 400, sotrable: false}
],
rowEditColumn:true,
checkColumn:true,
searchDiv:$("#gridSearch"),
buttons:[{tag:"add",show:true,click:function () {
layer.alert('你点击了增加操作',{icon:1});
}},
{tag:"edit",show:true,click:function (rows) {
layer.alert('你点击了编辑操作,选择的记录查看rows数组',{icon:2});
console.log(rows);
}},
{tag:"delete",show:true,click:function (rows) {
layer.alert('你点击了删除操作,选择的记录查看rows数组',{icon:3});
console.log(rows);
}},
{tag:"refresh",show:true}],
rowButtons:[{tag:"edit",show:true,click:function (row,index) {
layer.alert('你点击了edit操作,选择的记录查看rows数组,点击的记录是参数的row,序号是参数的index',{icon:4});
console.log(row);
console.log(index);
}},{tag:"delete",show:true,click:function (row,index) {
layer.alert('你点击了delete操作,选择的记录查看rows数组,点击的记录是参数的row,序号是参数的index',{icon:4});
console.log(row);
console.log(index);
}}]
});
1.1)底部的导航条的代码
buttons:[{tag:"add",show:true,click:function () {
layer.alert('你点击了增加操作',{icon:1});
}},
{tag:"edit",show:true,click:function (rows) {
layer.alert('你点击了编辑操作,选择的记录查看rows数组',{icon:2});
console.log(rows);
}},
{tag:"delete",show:true,click:function (rows) {
layer.alert('你点击了删除操作,选择的记录查看rows数组',{icon:3});
console.log(rows);
}},
{tag:"refresh",show:true}],
tag:表示按钮的标志位,默认有四个标志位add,delete,update,refresh,可以自定义,具体的请看高级功能
show:表示这个功能是否显示
click:当按钮点击的时候执行的方法
注意这个方法的使用,带一个rows的参数,rows是当前grid选择的数据。
例如下列的代码
{tag:"delete",show:true,click:function (rows) {
layer.alert('你点击了删除操作,选择的记录查看rows数组',{icon:3});
console.log(rows);
}},
layer我用的layer的插件,大家可以下看看,国人写的,很不错,我的目标,哈哈。