easyui datagrid中加入滑块
datagrid:
{
field: 'IsCurrent', title: 'xxxx', width: 20,
formatter: function (value, row, index) {
if (value == 2) {
return "<input id=" + row.ID + " class='easyui-switchbutton' checked data-options=\"onText:'是',offText:'否', onChange:onSwitchButtonChange\">";
} else {
return "<input id=" + row.ID + " class='easyui-switchbutton' data-options=\"onText:'是',offText:'否', onChange:onSwitchButtonChange\">";
}
}
},
]],
onLoadSuccess: function (data) {
$.parser.parse('#datagrid父框体id');
}
});
滑块移动方法:
function onSwitchButtonChange() {
var isCurrent = 0;
if ($(this).switchbutton("options").checked) {
isCurrent = 2;
}
$.ajax({
type: 'post',
url: '你的请求地址',
data: {
"id": $(this).attr("id"),
"isCurrent":isCurrent
},
success: function () {
}
});
}