天天看點

bootstrap-table 可編輯下拉框 插件editable中source,validate中無法擷取本行資料row

解決方案:

validate: function (value) {
    var data = $table.bootstrapTable('getData'),
        index = $(this).parents('tr').data('index');

    console.log(data[index]); // row data
}
           
source: function (value) {
    var data = $table.bootstrapTable('getData'),
        index = $(this).parents('tr').data('index');

    console.log(data[index]); // row data
}                例子:      
{
    field: 'containerType',
    align: 'center',
    title: '箱型',
    editable: {
        type: 'select',
        title: '箱型',
        formatter: function (value) {
            return getDescriptionByDict(emptyContainerTypeDict, value);
        },
        source: function () {
            
            var data = $table.bootstrapTable('getData'),
                index = $(this).parents('tr').data('index');
            console.log(data[index]); // row data

            var result = [];
            $.each(emptyContainerTypeDict, function (key, value) {
                result.push({value: value.dictValue, text: value.dictLabel});
            });
            return result;
        }
    }
}