预期结果:如果 row.updated_status 等于 '1',将禁用这两个字段 'UOM' 和 'allocated_qty',否则保留。
问题:无法禁用这两个字段。
"columns": [
{
"field": "id", "title": "Id", "visible": false
},
{
"field": "product__name", "title": "Product"
},
{
"field": "uom", "title": "UOM", "formatter": "uomFormatter"
},
{
"field": "allocated_qty", "title": "Alloc. Qty",
"editable": {"mode": "inline"}
}],
"rowStyle": "rowStyle"
在javascript中: 对于“UOM”字段:
function uomFormatter(value, row, index){
var uom_list = row.uom_list;
var product_id = row.product_id;
if(product_id != null && product_id != ''){
if(row.updated_status == 1){
if(uom_list != null){
var html = '<select class="form-control defaultpicker uom_list" data-row-index="' + index + '" disabled>';
...the following codes...
}else{
...the following codes...
}
}
else{
if(uom_list != null){
var html = '<select class="form-control defaultpicker uom_list" data-width="120px" data-row-index="' + index + '">';
}
}
对于字段“allocated_qty”:
function rowStyle(row, index) {
if(row.updated_status == 1){
$('#bootstrap-table').bootstrapTable('disabledColumn', 'allocated_qty');
}
}
最佳答案
应该禁用,而不是禁用:
var html = '<select class="form-control defaultpicker uom_list" data-row-index="' + index + '" disabled>';
关于javascript - 如何禁用 $ ('#bootstrap-table' 中的选定字段),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53735469/