I am working with Blazor Server using the Radzen library and MongoDB. I am wondering if anyone knows how to read data from two different collections and display it in one table. I have ID references to other tables. Is it possible to use those to read the data of other collections or do I have to copy the data from one collection into the other to read all the values?
I have tried changing the TItem under the Column field from Classes to TimeWindow and the property to StartDate (in the case of trying to get the Time field to display) and all that caused it do was not render. When I leave it as TItem = "Classes" It renders the Id stored in classes (posted example). I have also made sure that both tables can be rendered separately so I know it isn't a problem with mapping the data from mongo to c#. Any help is appreciated.
example document 1 (classes):
{
"_id" : ObjectId("637545927a45e617da1cba8e"),
"Grades" : [
],
"CRN" : 1000,
"Attendance" : [
],
"Enrolled" : [
],
"AttendanceDate" : [
],
"CourseName" : "Themes in U.S. History",
"PotentialID" : "AS536",
"Section" : "0",
"Prerequiste" : [
],
"MinimumRequirement" : [
],
"Description" : "The course is an introduction to major issues in the history of the United States, from colonial times to the twentieth\r\ncentury. Topics may include: the origins of slavery and racism; industrialization and the growth of cities and suburbs;\r\nthe growth of the American empire; movements for social change.",
"RoomID" : 56,
"BuildingID" : 2,
"Type" : "Undergraduate",
"Credits" : 4,
"MaxCapacity" : 25,
"Day" : "Tuesday & Thursday",
"Professor" : ObjectId("638be8c63d5b3e062b56f8f4"),
"Department" : "American Studies",
"Time" : ObjectId("640e52efaabb89419c88138b")
}
example document 2 (timeWindow, matches with the Time id from example 1)
{
"_id" : ObjectId("640e52efaabb89419c88138b"),
"Semester" : "Fall",
"Period" : "Period 1",
"StartDate" : ISODate("2019-09-04T13:00:00.000+0000"),
"EndDate" : ISODate("2019-12-22T14:30:00.000+0000"),
"GradeLimit" : ISODate("2019-12-23T00:00:00.000+0000"),
"RegistrationLimit" : ISODate("2019-11-16T00:00:00.000+0000"),
"WithdrawLimit" : ISODate("2019-09-07T00:00:00.000+0000")
}
page.razor
@page "/page"
<RadzenDataGrid AllowFiltering="true" AllowColumnResize="false" AllowAlternatingRows="true" FilterMode="FilterMode.Advanced" AllowSorting="true" PageSize="15" AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true" Data="@queryUser" TItem="Classes" ColumnWidth="300px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn TItem="Classes" Property="CourseName" Title="Course Name" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Section" Title="Section" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Description" Title="Description" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="RoomID" Title="Room ID" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="BuildingID" Title="Building ID" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Type" Title="Type" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Professor" Title="Professor" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Department" Title="Department" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="CRN" Title="CRN" Frozen="true" Width="0px" />
<RadzenDataGridColumn TItem="Classes" Property="Time" Title="Time" Frozen="true" Width="0px" />
</Columns>
</RadzenDataGrid>
@code
{
Mongo mongo = new Mongo("database");
IEnumerable<Classes> queryUser;
IEnumerable<TimeWindow> queryTime;
protected override async Task OnInitializedAsync()
{
queryUser = mongo.LoadRecord<Classes>("classes");
queryTime = mongo.LoadRecord<TimeWindow>("timeWindow");
}
}