disabled: false, //是否禁⽤编辑
emptytext: "空⽂本", //空值的默认⽂本
mode: "popup", //编辑框的模式:⽀持popup和inline两种模式,默认是popup validate: function (value) { //字段验证
if (!$.trim(value)) {
return '不能为空';
}
}
});
});
var curRow = {};
$(function () {
$("#tb_user").bootstrapTable({
toolbar: "#toolbar",
idField: "Id",
pagination: true,
showRefresh: true,
search: true,
clickToSelect: true,
queryParams: function (param) {
return {};
},
url: "/Editable/GetUsers",
columns: [{
checkbox: true
}, {
field: "UserName",
title: "⽤户名",
formatter: function (value, row, index) {
return "";
}
}, {
field: "Age",
title: "年龄",
}, {
field: "Birthday",
title: "⽣⽇",
formatter: function (value, row, index) {
var date = eval('new ' + eval(value).source) return date.format("yyyy年MM⽉dd⽇");
}
},
{
field: "DeptName",
title: "部门"
}, {
field: "Hodd",
title: "爱好"
}],
onClickRow: function (row, $element) { curRow = row;
},
onLoadSuccess: function (aa, bb, cc) { $("#tb_user a").editable({
url: function (params) {
var sName = $(this).attr("name");
curRow[sName] = params.value;
html表格元素$.ajax({
type: 'POST',
url: "/Editable/Edit",
data: curRow,
dataType: 'JSON',
success: function (data, textStatus, jqXHR) { alert('保存成功!');
},
error: function () { alert("error");}
});
},
});
},
});
});
$(function () {
$("#tb_user").bootstrapTable({ toolbar: "#toolbar",
idField: "Id",
pagination: true,
showRefresh: true,
search: true,
clickToSelect: true, queryParams: function (param) { return {};
},
url: "/Editable/GetUsers", columns: [{
checkbox: true
}, {
field: "UserName",
title: "⽤户名",
editable: {
type: 'text',
title: '⽤户名',
validate: function (v) {
if (!v) return '⽤户名不能为空';
}
}
}, {
field: "Age",
title: "年龄",
}, {
field: "Birthday",
formatter: function (value, row, index) {
var date = eval('new ' + eval(value).source)
return date.format("yyyy-MM-dd");
}
},
{
field: "DeptName",
title: "部门"
}, {
field: "Hobby",
title: "爱好"
}],
onEditableSave: function (field, row, oldValue, $el) { $.ajax({
type: "post",
url: "/Editable/Edit",
data: row,
dataType: 'JSON',
success: function (data, status) {
if (status == "success") {
alert('提交数据成功');
}
},
error: function () {
alert('编辑失败');
},
complete: function () {
}
});
}
});
});
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论