|
@using Syncfusion.Blazor.SplitButtons
<SfButtonGroup Mode="SelectionMode.Multiple">
<ButtonGroupButton Selected="true">Bold</ButtonGroupButton>
<ButtonGroupButton Selected="true" >Italic</ButtonGroupButton>
<ButtonGroupButton >Underline</ButtonGroupButton>
</SfButtonGroup>
|
|
@using Syncfusion.Blazor.SplitButtons
<SfButtonGroup Mode="SelectionMode.Multiple" Created="created">
<ButtonGroupButton>Left</ButtonGroupButton>
<ButtonGroupButton @ref="CenterBtn">Center</ButtonGroupButton>
<ButtonGroupButton>Right</ButtonGroupButton>
</SfButtonGroup>
@code{
public ButtonGroupButton CenterBtn { get; set; }
public void created()
{
CenterBtn.Selected = true;
}
}
|
The above is not a real world scenario. You do not hardcode everything in real life. Please provide us an example for a real world scenario.
Scenario 1: Button group uses a property in a model called Priority (int). The priority property can be 1, 2 or 3. The buttons use these ints as its value, and the text is "Low", "Medium" and High in the button group buttons.
reading from the database, if the value is 2, Medium will be selected in the UI. If the user clicks on "High" the bound priority field is updated to int "3".
Scenario 2:
You have a list of values that comes from a model (Database driven, NOT hardcoded). For each of those values, you need to create a button in the button group. The button group is bound to another property value, which is set when that respective button is clicked.
Thanks.
|
<EditForm Model="_model">
<InputRadioGroup @bind-Value="@_model.SelectedManufacturer">
Manufacturer:
<br>
<div class='e-btn-group'>
@foreach (var manufacturer in Manufacturers)
{
string id_name = "id";
<InputRadio Value="manufacturer" @attributes="new Dictionary<string, object> { { id_name, manufacturer }}"/>
<label for="@manufacturer" class="e-btn">@manufacturerlabel>
}
div>
InputRadioGroup>
EditForm>
<p> Selected Item: @_model.SelectedManufacturerp>
@code {
List
FormClass _model = new FormClass();
class FormClass
{
public String SelectedManufacturer { get; set; } = "Tesla";
}
}
<style>
.e-btn-group {
margin: 25px 5px 20px 20px;
}
style>
|
So the suggested way to use the ButtonGroup control is use standard HTML? Even for Syncfusion this seems crazy?!
Hi Alex,
Currently, we don't have support for customer-requested requirements. That's why we suggested InputRadio in the previous update. However, we have already considered this an improvement. And we have planned to include this in any of our upcoming releases.
Regards,
Janakiraman S.
Hi All!
I still don't see this feature in the ButtonGoup. Am I missing something??
Kind regards,
Judi Smith
Hi Judi,
We do not have immediate plan to implement this feature and it will be included in any of our upcoming releases. Please cast your vote to make it count. So that we will prioritize the features for every release based on demands. Please track the status using, below feedback link.
Please let us know if you need any further assistance on this.
Regards,
KeerthiKaran K V
Hi All,
We can achieve your requirement the two-way binding support by using the Selected property of the button group button tag in button group components. Refer to the below code snippet and sample link.
|
<SfButtonGroup Mode="Syncfusion.Blazor.SplitButtons.SelectionMode.Single"> <ButtonGroupButton @bind-Selected="@FirstSelected">First</ButtonGroupButton> <ButtonGroupButton @bind-Selected="@SecondSelected">Second</ButtonGroupButton> <ButtonGroupButton @bind-Selected="@ThirdSelected">Third</ButtonGroupButton> </SfButtonGroup>
|
Sample link: https://blazorplayground.syncfusion.com/LZrpsDVrhBMCWKKX
Kindly check with above solution and get back to us if you need any further assistance.
Regards,
YuvanShankar A