<GridPageSettings PageSize="50" /> <EjsDataManager Adaptor="Adaptors.ODataV4Adaptor" Url=@(RestClient.RootUrl + "odata/utilisateurs") /> <GridColumns> <GridColumn Field="Id" HeaderText="ID" IsPrimaryKey=true Visible="false"></GridColumn> <GridColumn Field="Nom" HeaderText="Nom" Width="auto"></GridColumn> <GridColumn Field="Nom" HeaderText="Prénom" Width="auto"></GridColumn> <GridColumn Field="Service.Nom" HeaderText="Service" Width="auto"></GridColumn> <GridColumn Field="Date" HeaderText="CreationDate" Format="yMd" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> <GridColumn Field="Mel" HeaderText="Mel" TextAlign="TextAlign.Right" Width="120"></GridColumn> </GridColumns> </EjsGrid> |
If I use this, here is he ODataV4 query :
| http://localhost:7121/api/odata/utilisateurs?$count=true&$skip=0&$top=50 |
You see that there is no select and expand for the "Service" navigation property.
And the answer
| {"@odata.context":"http://localhost:7121/api/odata/$metadata#Utilisateurs","@odata.count":1,"value":[{"Id":"f63a02c7-4a37-491f-a13b-4d680429f1c7","DateCreation":"2020-02-19T07:16:04.44+01:00","UtilisateurCreation":null,"Modification":null,"UtilisateurModification":null,"Login":"admin","MotDePasse":"XXX","Prenom":"Brice","DeuxiemePrenom":null,"Nom":"FROMENTIN","Mel":"XXX","Telephone":null,"Fax":null,"IdService":"f4c8499f-da3b-430e-ad39-d5aaab8beae3"}]} |
Is there a way to automagically :) have select and expand be used ?
Thx
Brice.
|
<EjsGrid TValue="ExpandoObject" AllowResizing="true" Query="@QueryData" AllowPaging="true" AllowSorting="true" AllowFiltering="true" Width="100%" Height="100%">
. . . .. . .
</EjsGrid>
@code{
public Query QueryData = new Query().Select(new List<string>() {"Service"}).Expand(new List<string>() { "Service" });
}
|
| <GridColumn Field="Service.Nom" HeaderText="Service" Width="auto"></GridColumn> |
Even if it is OK in the server response, nothing is displayed :(
Do you think that the automatic select&display should become an option to enhance the performance and network consumption ?
Brice.
@page "/"
@using System.ComponentModel.DataAnnotations;
@using System.Dynamic;
@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.Grids
<EjsGrid TValue="ExpandoObject" AllowPaging="true" AllowSelection="true" AllowFiltering="true" Toolbar="@(new List<string>() { "Search"})" Query="@QueryData">
<EjsDataManager Url="http://localhost:64956/odata/books" Adaptor="Adaptors.ODataV4Adaptor"></EjsDataManager>
<GridColumns>
<GridColumn Field="Guid" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Right" Width="90"></GridColumn>
<GridColumn Field="Title" HeaderText="Customer Name" Width="90"></GridColumn>
<GridColumn Field="Author" HeaderText="Employee ID" Width="90"></GridColumn>
<GridColumn Field="Site.SiteName" HeaderText="Sitio" TextAlign="TextAlign.Left" Width="40">
</GridColumn>
</GridColumns>
</EjsGrid>
@code{
public Query QueryData = new Query().Expand(new List<string> { "Site" });
public class Site
{
public Guid Id { get; set; }
public string SiteName { get; set; }
public List<Book> Books { get; set; } = new List<Book>();
}
public class Book
{
[Key]
public Guid Guid { get; set; }
public Guid? SiteId { get; set; }
public Site Site { get; set; }
public int Id { get; set; }
public string ISBN { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public decimal Price { get; set; }
}
}
Brice.
<EjsDataManager Url="http://localhost:64956/odata/books" Adaptor="Adaptors.ODataV4Adaptor"></EjsDataManager>
<GridColumns>
<GridColumn Field="Guid" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Right" Width="90"></GridColumn>
<GridColumn Field="Title" HeaderText="Customer Name" Width="90"></GridColumn>
<GridColumn Field="Author" HeaderText="Employee ID" Width="90"></GridColumn>
<GridColumn Field="Site.SiteName" HeaderText="Sitio" TextAlign="TextAlign.Left" Width="40">
<Template>
@{
dynamic text = (context as ExpandoObject);
<span>@text.Site.SiteName</span>
}
</Template>
</GridColumn>
</GridColumns>
</EjsGrid>
|