I'm using bootstrap table to select data for my form and but I have a problem to select from sorted or searched table is there any way to get data? Or I should sort or search in my list by my own?
This is how I get the row:
var row = allData[$("#tableId .selected").index()];
That I think it was the worst idea!!
And this is where table fills:
$('#tableId').bootstrapTable({
columns: columnsStyle,
data: allData
});
result is a list of objects.
I find a trick that it works but if there is still a way using bootstrap I appreciate it.
I added a column to append an id to every row as below:
columnsStyle = [
{
field: "dataRowIndex",
title: "",
class: "d-none",
searchable: false
},
otherColumns...
]
then I filled it like this:
for (var i = 0; i < allData.length; i++) {
allData[i]["dataRowIndex"] = i;
}
And get the selected row using code below:
var row = allData[parseInt($("#tableId .selected .rowIndex").html())];