bootstrap table一般注重一列中所有行都是一个处理方式,很少对应有同一列不同行要处理成不同的形式。但是formate啊,index啊,这些倒是随着行变化。
那么结合x-editable呢,它本身type只支持text,select等string,不支持function,那么改造一下。
页面:type:function(){}或者type(){}
{field: 'inputvalue',title: '数值',halign: "center",align: "center",valign: "middle",editable: {// noEditFormatter (value, row, index) {// console.log(value)// if (value === 'noEdit') {// return 'No Edit'// }// return false// },type(){// console.log(value)var pk = $(this).attr("data-pk");var selectRow3 = $('#table0').bootstrapTable('getRowByUniqueId', pk);if (selectRow3.resulttype=="SExpr"){edittype='select'}else{edittype='text'}return edittype},source: function(){var pk = $(this).attr("data-pk");var selectRow3 = $('#table0').bootstrapTable('getRowByUniqueId', pk);if (selectRow3.resulttype=="SExpr"){var arr=selectRow3.selectvaluereturn arr}},select: {allowClear: true,width: '150px',placeholder: '请选择',// multiple: true}, pk: 1,title: '选择',params: function(params) {params.bb = 'select';return params;}},formatter: onMsoNumberFormat
bootstrap-editable.js——添加了下面第4行开始到11行。
createInput: function(options) {var TypeConstructor, typeOptions, input,type = options.type;// var type;if ($.isFunction(options.type)) {type = options.type.call(options.scope);console.log(type)// this.sourceData = null;//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed} else {type = options.type;}
效果如下,不同行根据某列值的需要,采用text或select。