Pass Parameter to control

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:



1 Reply

MS Monisha Saravanan Syncfusion Team March 14, 2022 12:55 PM UTC

Hi Luigi, 

Greetings from Syncfusion support. 

We have analyzed your query and  we suggest you to use Query property or Headers property of Grid to achieve your requirement. Query property of Grid is used to send additional parameters to server. Whereas Headers property of SfDataManager is used to send additional parameter to server along with request.  

Kindly refer the below UG for additional information. 


Kindly get back to us if you need further assistance. 

Regards, 
Monisha 


Loader.
Up arrow icon