bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Single select across tables doesn't update selections

Open matan1008 opened this issue 2 years ago • 5 comments

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: image 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

matan1008 avatar Aug 23 '22 19:08 matan1008

Please provide an Online Example to show your problem, thanks!

djhvscf avatar Aug 29 '22 20:08 djhvscf

https://live.bootstrap-table.com/code/matan1008/12651

matan1008 avatar Aug 29 '22 20:08 matan1008

@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 avatar Aug 30 '22 07:08 UtechtDustin

@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.

matan1008 avatar Aug 30 '22 07:08 matan1008

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.

UtechtDustin avatar Aug 30 '22 07:08 UtechtDustin

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

wenzhixin avatar May 10 '24 03:05 wenzhixin