Hi,
I want to set up two grids such that when I click on the higher one on a certain row, all of the associated entities are selected and displayed.
Something like what is seen at the bottom of the https://blazor.syncfusion.com/documentation/datagrid/row#detail-template at
"Master Detail Datagrid"
.
Even though I followed the steps in the example, it does not work as expected.
My code looks like this:
<SfGrid DataSource="Bets" AllowPaging="true" AllowSelection="true">
<GridPageSettings PageSize="7"></GridPageSettings>
<GridEvents RowSelected="RowSelectHandler" TValue="Bet"></GridEvents>
<GridColumns>
<GridColumn Field="@nameof(Bet.BetId)" HeaderText="ID"></GridColumn>
<GridColumn Field="@nameof(Bet.Stake)" HeaderText="Stake"></GridColumn>
<GridColumn Field="@nameof(Bet.TotalOdds)" HeaderText="Total Odds"></GridColumn>
<GridColumn Field="@nameof(Bet.PotentialWin)" HeaderText="Potential Win" Format="C2"></GridColumn>
<GridColumn Field="@nameof(Bet.BetDate)" Format="d" HeaderText="Bet Date" Type="ColumnType.Date"></GridColumn>
<GridColumn Field="@nameof(Bet.Bookmaker)" HeaderText="Bookmaker"></GridColumn>
<GridColumn Field="@nameof(Bet.Status)" HeaderText="Status"></GridColumn>
</GridColumns>
</SfGrid>
<br />
<center>
<div>
Events for selected bet.
</div>
</center>
<SfGrid DataSource="Events" Query="@(new Query().Where("BetId", "equal", RowIndex))">
</SfGrid>
@code {
public IEnumerable<Bet> Bets { get; set; }
public IEnumerable<Event> Events { get; set; }
public Guid? RowIndex { get; set; }
protected override async Task OnInitializedAsync()
{
Bets = await RepositoryWrapper.BetRepository.GetAllBetsAsync();
Events = await RepositoryWrapper.EventRepository.GetAllEventsAsync();
}
public void RowSelectHandler(RowSelectEventArgs<Bet> Args)
{
RowIndex = Args.Data.BetId;
}
}
and two related entities to this topic are:
public class Bet
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public Guid BetId { get; init; }
public decimal TotalOdds { get; set; }
public decimal Stake { get; set; }
public DateTime BetDate { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public int DayOfWeek { get; set; }
public string? Bookmaker { get; set; }
public BetStatusEnum Status { get; set; } = BetStatusEnum.Unfinished;
public bool IsTaxIncluded { get; set; } = true;
public decimal PotentialWin
{
get
{
decimal win = Math.Round(Stake * TotalOdds);
return IsTaxIncluded ? win * 0.86M : win;
}
}
// Relationships
public virtual ICollection<Event> EventsList { get; set; }
}
and
public class Event
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public Guid EventId { get; init; }
[Required]
public double Odds { get; set; }
public BetStatusEnum Status { get; set; } = BetStatusEnum.Unfinished;
// Relationships
public int CategoryId { get; set; }
public virtual Category Category { get; set; }
public int EventTypeId { get; set; }
public virtual EventType EventType { get; set; }
public Guid? BetId { get; set; }
public virtual Bet Bet { get; set; }
}
Is this something related to primary key being defined as Guid?
Hi Krzysztof Palonek,
We are unable to reproduce the reported issue when attempting to do so using
the latest version 26.2.12. For your reference, we have attached a screenshot
and a simple sample. So, to proceed with the reporting problem, we require
some additional clarification from you. Please share the details below to
proceed further at our end.
|
|
Above-requested
details will be very helpful in validating the reported query at our end and
providing a solution as early as possible. Thanks for your understanding.
Regards,
Prathap Senthil
I've pinpointed the issue. I selected "None" in the Interactive render mode when creating the project. It must be set to a mode other than "None.
Hi Krzysztof Palonek,
Based on the reported problem, it
seems you are experiencing an issue with your .NET 8 project. To overcome the
reported problem, please
try the suggested changes below, Add the RenderMode.InteractiveServer option to
your Razor pages to resolve the problem.
|
@page "/bets" @using Domain.Contracts @rendermode InteractiveServer <BetsComponent></BetsComponent> |
For more detailed insights, please visit the following blog and documentation.
Blog: https://www.syncfusion.com/blogs/post/blazor-ui-support-dotnet-8.aspx
UG: https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-web-app
Documentation: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0|
Regards,
Naveen