最近公司要求比较恶心,为什么这么说呢,给我一个前端的需求来让我做,却是很难,也很恶心,而且我也找了公司前端的高手,最后还是解决了.
接下来说一下我是怎么做的。
需求就是我的展示列表是有一些是默认选中的,不让勾选:如图:
然后就是js代码解决问题
onColumnSwitch: function (field, checked) {
$('.dropdown-menu .dropdown-item').each((index,item)=>{
if($(item).find('span').text() == 'Item库存'){
$(item).find('input').attr('disabled',true)
}
})
}
下面的是设置默认选中的
$('#table').ready(function(){
$('.dropdown-menu .dropdown-item').each((index,item)=>{
if($(item).find('span').text() == 'Item库存'){
$(item).find('input').attr('disabled',true)
}
})
});
我这里是只展示Item库存,并且是不能选中。