Hello,
when page load I want to filter data in grid by parameter (
@_authMessage
).
this is my razor page:
@page "/paziente"
@layout MainLayout
@inject IJSRuntime JSRuntime;
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<SfGrid TValue="Paziente" AllowPaging="true" AllowFiltering="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" Height ="315">
<SfDataManager Url="/api/Paziente" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(Paziente.Id)" IsPrimaryKey="true" Visible="false"></GridColumn>
<GridColumn Field="@nameof(Paziente.Id_Medico)" Visible="false" DefaultValue="@_authMessage"></GridColumn>
<GridColumn Field="@nameof(Paziente.Cognome)" Width="150"></GridColumn>
<GridColumn Field="@nameof(Paziente.Nome)" Width="150"></GridColumn>
<GridColumn Field="@nameof(Paziente.Cellulare)" Width="0"></GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
</div>
@code {
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
private string _authMessage="";
protected override void OnInitialized()
{
LogUsername();
}
private async Task LogUsername()
{
var authState = await authenticationStateTask;
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
_authMessage = $"{user.Identity.Name}";
}
else
{
_authMessage = "";
}
}
}
This is a control method: