bootstrap-table
bootstrap-table copied to clipboard
Single select across tables doesn't update selections
Bootstraptable version(s) affected
1.21.0
Description
Trying to create single select across tables doesn't update the selected items (by style) across tables.
In the following example:
I would like the previously selected row, Item 2 in the example (which is now not selected), to change its style back to the unselected style.
Moreover, running
bootstrapTable('getSelections')
on the second table returns the "selected" row.
Example(s)
<table
id="table"
data-toggle="table"
data-select-item-name="name1"
data-height="250"
data-url="json/data1.json">
<thead>
<tr>
<th data-radio="true"></th>
<th data-field="id">ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
<table
id="table"
data-toggle="table"
data-select-item-name="name1"
data-height="250"
data-url="json/data1.json">
<thead>
<tr>
<th data-radio="true"></th>
<th data-field="id">ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
Possible Solutions
No response
Additional Context
No response
Please provide an Online Example to show your problem, thanks!
https://live.bootstrap-table.com/code/matan1008/12651
@matan1008 you set name1
as name for both checkboxes.
Change the selectItemName option for one tabel and you can select the radio buttons for both tables sepratly.
Example: https://live.bootstrap-table.com/code/UtechtDustin/12654
Does this fix your issue ?
@UtechtDustin Sorry, I probably wasn't clear enough.
I want a single select that will work between tables, see https://github.com/wenzhixin/bootstrap-table/issues/6229 (I changed the selectItemName
according to the reply there).
So if you select an item in the first table and then select an item in the second table, the item in the first table will be deselcted.
Oh okay, i think @wenzhixin also understand it wrong.
His example also have two different selectItemName
names.
Let us check, how we detect if the state of the radio has changed.
Your use case is a particular case and should not be considered a general practice so you can handle it individually.
An example to solve the problem: https://live.bootstrap-table.com/code/wenzhixin/17636