博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
十五、bootstrap-table editable
阅读量:4133 次
发布时间:2019-05-25

本文共 2750 字,大约阅读时间需要 9 分钟。

使用表格的时候,避免不了增删改查,下面就把自己使用bootstrap-table editable的过程记录一下

第一步,下载
bootstrap-editable.css v1.5.1
bootstrap-editable.min.js v1.5.1
bootstrap-table-editable.js
当然jquery和bootstrap的js和css都是必须的

第二步,html中添加引用

    

第三步,编写js

$('#show_product').bootstrapTable({    toolbar: '#toolbar', //工具按钮用哪个容器    striped: true, //是否显示行间隔色    cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)    pagination: false, //是否显示分页(*)    sortable: true, //是否启用排序    sortOrder: "asc", //排序方式    sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)    pageNumber: 1, //初始化加载第一页,默认第一页    pageSize: 10, //每页的记录行数(*)    pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)    clickToSelect: false,    showExport: true, //是否显示导出    exportDataType: "selected", //basic', 'all', 'selected'.    columns: [{ checkbox: true }, {        field: "id",        title: 'Id',        visible: false    }, {        field: "name",        title: '名称'    }, {        field: "shortName",        title: '简称'    }, {        field: "barCode",        title: '一维码',        editable: {            type: 'text',            mode: 'inline'//直接在所在行编辑,不弹出        },        sortable: true    }, {        field: "remark",        title: '备注'    }, ],    onEditableSave: function(field, row, oldValue, $el) {
var newValue = row[field];//不能使用row.field if (!checkStrEqual(oldValue, newValue)) { $.ajax({ type: "post", url: "/edit", data: { 'type': 'product', 'id': row.id,//获得所在行指定列的值 'newValue': newValue, 'field': field, 'oldValue':oldValue }, success: function(data, status) {
if (status == "success") { alert("编辑成功"); } }, error: function() {
alert("Error"); }, complete: function() {
} }); } }});

第四步,python后端

class UpdateHandler(BasicWithOperateDBHandler):    '''    编辑信息    '''    def post(self):        typee = self.get_argument("type")        tableId = self.get_argument("id")        field = self.get_argument("field")        oldValue = self.get_argument("oldValue")        newValue = self.get_argument("newValue")        try:            if typee == 'product':                self.odb.executeSql(allSQL.updateProduct % (field, newValue, tableId))            self.write({
'status':'success'}) except: traceback.print_exc() self.write({
'status':'failed'})

引用的文章:

bootstrap-table editable例子:

转载地址:http://diivi.baihongyu.com/

你可能感兴趣的文章
XML生成(三):JDOM生成
查看>>
Ubuntu Could not open lock file /var/lib/dpkg/lock - open (13:Permission denied)
查看>>
collect2: ld returned 1 exit status
查看>>
C#入门
查看>>
C#中ColorDialog需点两次确定才会退出的问题
查看>>
数据库
查看>>
nginx反代 499 502 bad gateway 和timeout
查看>>
linux虚拟机安装tar.gz版jdk步骤详解
查看>>
python实现100以内自然数之和,偶数之和
查看>>
python数字逆序输出及多个print输出在同一行
查看>>
苏宁产品经理面经
查看>>
百度产品经理群面
查看>>
去哪儿一面+平安科技二面+hr面+贝贝一面+二面产品面经
查看>>
element ui 弹窗在IE11中关闭时闪现问题修复
查看>>
vue 遍历对象并动态绑定在下拉列表中
查看>>
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>