bootstrap-table
bootstrap-table copied to clipboard
Updated checkboxes and radios to match bootstrap 5
🤔Type of Request
- [ ] Bug fix
- [ ] New feature
- [x] Improvement
- [ ] Documentation
- [ ] Other
🔗Resolves an issue? N/A
📝Changelog
Updated checkboxes and radios to match Bootstrap 5 styling (see https://getbootstrap.com/docs/5.3/forms/checks-radios/). This allows for other features like the color of the checkboxes/radios to match the bootstrap primary color when customized
- [x] Core
- [ ] Extensions
💡Example(s)? Before: https://live.bootstrap-table.com/code/Nickno95/14139 After: https://live.bootstrap-table.com/code/Nickno95/14140
☑️Self Check before Merge
⚠️ Please check all items below before reviewing. ⚠️
- [x] Doc is updated/provided or not needed
- [x] Demo is updated/provided or not needed
- [x] Changelog is provided or not needed
This PR would add the class
form-check-inputfor every theme e.g. semanticui.Please adjust it, so the class will only be used for BT5.
Any suggestion on best way for checking what the theme is set to in the javascript, maybe an example in the code that's already doing this? Another part of the issue in Bootstrap 5 is with needing an extra wrapping element that was not needed in Bootstrap 4, and I assume other frameworks don't need that either.
We already do that quite often, a few hints: https://github.com/wenzhixin/bootstrap-table/blob/ff06f54e48f8ffb4a7de2bb86e682997e5648ac1/src/constants/index.js#L8-L109 https://github.com/wenzhixin/bootstrap-table/blob/develop/src/themes/foundation/bootstrap-table-foundation.js#L21-L37 https://github.com/wenzhixin/bootstrap-table/blob/1a1c5cda6748997daf49d11d375788feea9f2747/src/bootstrap-table.js#L1248
Actually I noticed this my self today using the Columns toolbar dropdown. The checkboxes generated in the dropdown to toggle the column visibility are generated like:
<label class="dropdown-item dropdown-item-marker">
<input type="checkbox" data-field="name" value="0" checked="checked">
<span>Name</span>
</label>
and indeed does not use the BS theme (if using BS).
It would be great to have a way to have it generated as:
<label class="dropdown-item dropdown-item-marker">
<input class="form-check-input" type="checkbox" data-field="name" value="0" checked="checked">
<span>Name</span>
</label>
@UtechtDustin are you working on this yourself?
Just for reference if someone wants a quick but hack'ish solution.
$.BootstrapTable = class extends $.BootstrapTable {
initToolbar() {
super.initToolbar()
$(`${this.options.buttonsToolbar} input[type='checkbox']`).addClass('form-check-input me-2')
}
}
@marceloverdijk No, i'm not working on this issue right now.