I was wondering if how can I change the color of show or hide datagrid switch button.
Thanks Rahul
I already tried the toggle-switch-button customize appearance but it didn't work. I want a color blue and not pink
|
<SfSwitch CssClass="bar-color" @bind-Checked="isBarCheked"></SfSwitch><br />
@code {
private bool isBarCheked = false;
}
<style>
/* To customize switch color */
.e-switch-wrapper.bar-color .e-switch-inner.e-switch-active,
.e-switch-wrapper.bar-color:hover .e-switch-inner.e-switch-active .e-switch-on {
background-color: #ADD8E6;
border-color: #ADD8E6;
}
.e-switch-wrapper.bar-color .e-switch-inner,
.e-switch-wrapper.bar-color .e-switch-off , .e-switch-wrapper .e-switch-on{
background-color: #ADD8E6;
border-color: #ADD8E6;
}
.e-switch-wrapper.bar-color .e-switch-handle {
background-color: #0000FF;
}
.e-switch-wrapper:hover .e-switch-handle.e-switch-active,
.e-switch-wrapper:not(.e-switch-disabled):hover .e-switch-handle:not(.e-switch-active){
background-color: #0000FF;
}
</style> |
Thank you it work on my switch button. but when opening the grid I want the corresponding column to hide automatically.
|
<SfGrid @ref="DefaultGrid" DataSource="@Orders" Height="315">
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Center" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150" Visible="false"TextAlign="TextAlign.Center"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date"TextAlign="TextAlign.Center" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Center" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
|
|
<SfSwitch CssClass="bar-color" @bind-Checked="isBarCheked" ValueChange="Change" TChecked="bool?"></SfSwitch>
<br />
<SfGrid @ref="DefaultGrid" DataSource="@Orders" Height="315">
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Center" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150" Visible="false"TextAlign="TextAlign.Center"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date"TextAlign="TextAlign.Center" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Center" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
private bool? isBarCheked = true;
private SfGrid<Order> DefaultGrid;
. . .
private void Change(Syncfusion.Blazor.Buttons.ChangeEventArgs<bool?> args)
{
if (args.Checked == true)
{
this.DefaultGrid.ShowColumnAsync("Customer Name"); //show Customer Name Column
} else
{
this.DefaultGrid.HideColumnsAsync(new string[] { "Customer Name" }); //hide Customer Name column
}
}
}
|