bootstrap-table 行内编辑简单实现
来源:互联网 发布:传奇dbc数据说明 编辑:程序博客网 时间:2024/06/05 14:08
$('#table').bootstrapTable({ url: createUrl(''), striped: true, uniqueId: 'attrValue', columns: [{ title: 'ID', field: 'index', formatter: formatterIndex },{ title: '规格', field: 'attrValue', class: 'editable' },{ title: '价格', field: 'sellPrice', class: 'editable' },{ title: '操作', field: 'operate', formatter: formatterOperate }]});function formatterIndex(value, row, index){ var i = index + 1; if(i < 10){ return "0" + i; }else{ return i; }}function formatterOperate(value, row, index){ return "<button onclick='saveRow("+index+")' class='btn small'><i class='fa fa-edit'></i> 保存</button><button onclick='editRow("+index+")' class='btn small blue'><i class='fa fa-edit'></i> 编辑</button><button onclick='delRow(\""+row.attrValue+"\")' class='btn small red'><i class='fa fa-trash-o'></i> 删除</button>";}$("#addBtn").click(function(){ var data = { attrValue: '', sellPrice: '' }; $("#table").bootstrapTable('append', data); $("#table tr:last-child td.editable").each(function(){ $(this).html("<input>"); });});function saveRow(index, value){ var obj = $("#table tr:nth-child("+ (index+1) +") td.editable"); var attrValue = obj.first().find("input").val().trim(); var sellPrice = obj.last().find("input").val().trim(); var newData = { attrValue: attrValue, sellPrice: sellPrice }; $("#table").bootstrapTable('updateRow', { index: index, row: newData }); obj.find("input").remove();}function editRow(index){ $("#table tr:nth-child("+ (index+1) +") td.editable").each(function(){ var value = $(this).text(); $(this).html("<input value='"+value+"'>"); });}function delRow(value){ $("#table").bootstrapTable('removeByUniqueId', value);}
0 0
- bootstrap-table 行内编辑简单实现
- bootstrap-table行内编辑表格的实现
- bootstrap table 行内编辑 select2 多选问题
- bootstrap-table 实现单击单元格可编辑
- 基于bootstrap table分页数据及行内编辑和导出数据(一)
- 基于bootstrap table分页数据及行内编辑和导出数据(二)导出数据
- Angularjs bootstrap table多选(全选),支持单击行选中 ,实现编辑、删除功能
- bootstrap table 双击可编辑,添加、删除行
- Bootstrap table 简单示例
- bootstrap-table简单应用
- bootstrap table 简单使用
- Jquery实现行内编辑
- bootstrap table实现x-editable的行单元格编辑及解决数据Empty和支持多样式
- 简单粗暴的table行编辑保存
- 基于Bootstrap使用jQuery实现简单可编辑表格
- 基于Bootstrap使用jQuery实现简单可编辑表格
- Bootstrap Table 实现简单的查询和显示功能
- node和bootstrap-table实现最简单的服务端分页
- Android 轮播图的实现 自动+手动滑动+指示+点击事件
- Java实现Unicode码转为中文
- Jeecg使用多级菜单
- OA系统_流程节点动作的归纳
- Picasso加载本地
- bootstrap-table 行内编辑简单实现
- 网易编程题五,数字翻转(计算)
- oracle通过序列和触发器实现自增主键
- QLabel
- 编程面试题:字符串(四)
- 机器学习实战_KNN
- 4.vue.js实例:列表输出
- PSFTP上传文件到服务器
- sql支持emoji表情符