|
<SfGrid DataSource="@Orders" AllowSelection="false" EnableHover="false" Height="315">
<GridEvents QueryCellInfo="CustomizeCell" TValue="Order"></GridEvents>
<GridColumns>
. . . ..
</GridColumns>
</SfGrid>
@code{
public List<Order> Orders { get; set; }
. . .. . .
public void CustomizeCell(QueryCellInfoEventArgs<Order> args)
{
if (args.Column.Field == "CustomerID")
{
args.Cell.AddStyle(new string[] { "background-color:" + args.Data.Priority_Color + ";" });
}
}
|
|
|
|
public bool flag = false;
public async Task Update()
{
flag = true;
Order data = new Order() { OrderID = 1001, CustomerID = "ABCDE",Freight = 2.91 };
await this.Grid.UpdateRow(1, data);
}
public void CustomizeCell(QueryCellInfoEventArgs<Order> args)
{
if (flag)
{
if (args.Column.Field == "CustomerID")
{
args.Cell.AddStyle(new string[] { "background-color:" + args.Data.Priority_Color + ";" });
}
}
}
|
Hello
It is working, but cursor of selected cells is not visible.
Regards
Maciej
Hello
Selection of single cell is not visible after mouse clicked.
Olny in cells with style added in QueryCellInfoEvent (attached video demonstration).
1.Options of datagrid selection:
<GridSelectionSettings Mode="Syncfusion.Blazor.Grids.SelectionMode.Cell" Type="Syncfusion.Blazor.Grids.SelectionType.Single" CellSelectionMode="CellSelectionMode.Box"></GridSelectionSettings>
..
<GridEvents TValue="RotaEmployee"
QueryCellInfo="@CustomizeCell"
..
2.CSS
<style>
.e-cellselectionbackground, .e-selectionbackground, .e-pivotview .e-grid .e-rowsheader.e-selectionbackground, .e-pivotview .e-grid .e-columnsheader.e-selectionbackground {
background-color: mediumvioletred !important; }
</style>
3.I used:
public void CustomizeCell(QueryCellInfoEventArgs<RotaEmployee> args)
{
int ind = (int)args.Column.Index;
args.Cell.AddStyle(new string[] { "border: 1px solid rgb(233,233,233) !important;" });
args.Cell.AddStyle(new string[] { "margin: 0 0 0 0;" });
args.Cell.AddStyle(new string[] { "padding: 0 0 0 0;" });
if (rotaDay.DayHead.DayOfWeek == DayOfWeek.Saturday || rotaDay.DayHead.DayOfWeek == DayOfWeek.Sunday)
{
args.Cell.AddStyle(new string[] { "background-color:#f5e1df !important;" });
}
...
if (rotaDay.fiedlList_P != null && rotaDay.fiedlList_P.Count > 0 && rotaDay.fiedlList_P[0] != null && rotaDay.fiedlList_P[0].KodZmiana != "")
{
switch (rotaDay.fiedlList_P[0].KodZmiana)
{
case "D":
args.Cell.AddStyle(new string[] { "background-color:Yellow !important;" });
break;
...
Thank you for help.
Regards
Maciej
|
<style>
.e-grid td.e-cellselectionbackground {
background: mediumvioletred !important;
}
</style> |
Hi Rahul,
Thank you very much.
It is working.
I had to remove "important!" from CustomizeCell
public void CustomizeCell(QueryCellInfoEventArgs<RotaEmployee> args)
{
if (rotaDay.DayHead.DayOfWeek == DayOfWeek.Saturday)
{
args.Cell.AddStyle(new string[] { "background-color:#f5e1df !important;" });
}
still overwrite cell's color
...
args.Cell.AddStyle(new string[] { "background-color:#f5e1df " });
without "!important" looks properly
Regards
Maciej
Hi
After updating to version 24.1.43, adding a style to a cell stopped working.
public void Schedule_CustomizeCell(QueryCellInfoEventArgs<Employee> args)
{
args.Cell.AddStyle(new string[] { "background-color:red;" });
...
Is there any additional option to set?
best regards
Maciej
Hi Maciej,
We have considered it as a breaking issue and logged the defect report “The
QueryCellInfo event's add-style method is not working in the Grid after the
NuGet version 24.1.41” for the same. Thank you for taking time to report
this issue and helping us to improve our product. At Syncfusion, we are
committed to fixing all validated defects (subject to technological feasibility
and Product Development Life Cycle) and this fix will be included in our
upcoming patch release.
You can now track the current
status of your request, review the proposed resolution timeline, and contact us
for any further inquiries through this feedback link.
https://www.syncfusion.com/feedback/49621/the-querycellinfo-events-add-style-method-is-not-working-in-the-grid-after-the
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”
Until then we appreciate your patience.
Regards,
Prathap S
Thanks for the patience.
We are glad to announce that, we have included the fix for the reported issue “The QueryCellInfo event's add-style method is not working in the Grid after the NuGet version 24.1.41” in our 24.1.46 release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the NuGet package for latest fixes and features from below.
NuGet : https://www.nuget.org/packages/Syncfusion.Blazor.Grid
Release Notes: https://blazor.syncfusion.com/documentation/release-notes/24.1.46?type=all#data-grid
We thank you for your support and appreciate your patience in waiting for this release.