后端设置扩展方法
public static void setnumcheckbox<t>(this datagridcolumnbuilder<t> builder)
{
_ = builder.celltemplate(new js("checkboxcelltemplate"))
.editcelltemplate(new js("checkboxeditortemplate"))
.lookup(lookup => lookup.datasource(new object[] {
new {
label = "是",
value = 1,
},
new {
label = "否",
value = 0,
},
}).displayexpr("label").valueexpr("value"));
}前端添加单元格和编辑代码
const getnewdomid = (function () {
let id = 1;
return function () {
return id++;
};
})();
function checkboxeditortemplate(el, e) {
var domid = 'grid_cell_' + getnewdomid();
el.html(`<div id="${domid}"></div>`);
new vue({
el: '#' + domid,
template: `<el-checkbox v-model="state" v-on:change="onchange" />`,
data: {
state: e.value === 1,
},
methods: {
onchange(value) {
e.setvalue(value ? 1 : 0);
},
},
});
}
function checkboxcelltemplate(container, options) {
container.html(
`<div class="dx-checkbox-container ${
options.value === 1 ? 'dx-checkbox-checked' : ''
}"><span class="dx-checkbox-icon"></span></div>`
);
}以上就是asp.net core使用devextreme20将int列转为checkbox方法示例的详细内容,更多关于asp.net core将int列转为checkbox的资料请关注代码网其它相关文章!
发表评论