針對 bootstraptable 中 hiden 為 true 的列 。
隱藏列不會渲染為 DOM 元素,所以我們無法通過 DOM 元素獲取。
我們需要通過 bootstraptable 數據源的數據對象獲取,其中包含隱藏列的數據。
//獲取當前行的 bootstrap 數據對象 getDataRow = function (obj) { var index = obj.parent().parent().attr('data-index'); var data = $('#bootstrap-table').bootstrapTable('getData'); console.dir(index); console.dir(data); console.dir(data[index]); return data[index]; }
可以根據每行 tr 元素的 data-index 屬性獲取其行號。
通過 $('#bootstrap-table').bootstrapTable('getData') 獲取數據源對象,會返回一個數組。
我們根據行號取數組中的元素即可,隱藏的未隱藏的都在這個 Obj 中。