Hi!
I just want to ask for help because I can't make the DataGrid work in my Webassembly project but my other project with Server side it is working fine.
I follow the guide in your website and included false
The issue is on the first load of the page LoadData is not triggered.
Thank you!
enchev
July 28, 2020, 10:58am
2
Works normally on my end:
Hi Mr. enchev,
Good Day!
Thank You for the immediate response. I will try it in a new project and hope I succeed. I think there is no problem with it but it's not working. The LoadData is triggered only when you search/Filter.
Below is my code.
<div class="row">
<div class="col-md-12">
<RadzenGrid AllowFiltering="true" FilterCaseSensitivity="Radzen.FilterCaseSensitivity.CaseInsensitive" AllowPaging="true" PageSize="10" AllowSorting="true" Data="@applications" TItem="Application" ColumnWidth="200px" LoadData="@(args => GetData(args))" Count="@cnt">
<Columns>
<RadzenGridColumn TItem="Application" Property="AppID" Title="Application ID" />
<RadzenGridColumn TItem="Application" Property="LName" Title="Last Name" />
<RadzenGridColumn TItem="Application" Property="FName" Title="First Name" />
<RadzenGridColumn TItem="Application" Property="MName" Title="Middle Name" />
<RadzenGridColumn TItem="Application" Property="ExtName" Title="Ext. Name" />
<RadzenGridColumn TItem="Application" Property="Address" Title="Address" />
<RadzenGridColumn TItem="Application" Property="BrgyName" Title="Barangay" />
<RadzenGridColumn TItem="Application" Property="TownName" Title="Town" />
</Columns>
</RadzenGrid>
</div>
@code {
HttpClient Http = new HttpClient();
List<Application> applications = new List<Application>();
ApplicantInspectionGrid applicantInspection = new ApplicantInspectionGrid();
int cnt = 0;
async Task GetData(LoadDataArgs args)
{
try
{
applicantInspection.Top = args.Top.ToString();
applicantInspection.Skip = args.Skip.ToString();
applicantInspection.OrderBy = args.OrderBy;
applicantInspection.COAID = 114;
var stringPayload = JsonConvert.SerializeObject(applicantInspection);
var content = new StringContent(stringPayload, Encoding.UTF8, "application/json");
var response = await Http.PostAsync("http://localhost:50197/api/Application/GetApplicantForInspection", content);
var responseToString = await response.Content.ReadAsStringAsync();
JObject obj = JObject.Parse(responseToString);
applications = JsonConvert.DeserializeObject<List<Application>>(obj["Contents"].ToString());
cnt = Convert.ToInt32(JsonConvert.DeserializeObject(obj["Count"][0]["TotalRows"].ToString()));
//acctname = applications[0].AppName;
StateHasChanged();
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
}
enchev
July 29, 2020, 4:58am
4
Try to set null as initial value
2 Likes
Hi Mr. enchev,
It's working now. Thank you very much!
1 Like