I have a service which calls controller, which has cacheservice to send response data as location list based on customerId. As shown in below code, I am using it for paging. But I get null value at first response and then when I focus out and focus back to dropdown, I get the response. It would be better to understand based on code.
IndexFormPage.razor
<FormItem><Template><label for="tkbxLocationName" class="k-label k-form-label">@($"{locationFieldName} {MOM.Alias.Common.DTO.Name}")</label><div class="d-flex"><TelerikComboBox TItem="@LocationDropdownDTO" TValue="@(int)" ScrollMode="@DropDownScrollMode.Virtual" OnRead="@GetLocationItems" ItemHeight="60" PageSize="20" Size="@size" Rounded="@size" Placeholder="Select Location Name" Id="tkbxLocationName" TextField="@(nameof(LocationDropdownDTO.Name))" ValueField="@(nameof(LocationDropdownDTO.Id))" @bind-Value="@Dto.LocationId" OnChange="@OnLocationChange" ValueMapper="(val) => HandlelocationValueMapper(val)" @ref="@refLocationDropDown" AllowCustom="false" Width="@TaskCategoryFieldUpWidth" Filterable="true" Class="condition-field-width" FilterOperator="@((Telerik.Blazor.StringFilterOperator)ReusableFilterOperator)" DebounceDelay="@MOM.UI.Client.Constants.Common.SearchBoxDebounceDelay"><NoDataTemplate><MOM.UI.Client.Components.NoContent></MOM.UI.Client.Components.NoContent></NoDataTemplate><ComboBoxSettings><ComboBoxPopupSettings Height="200px" /></ComboBoxSettings> </TelerikComboBox> <TelerikValidationTooltip For="@(() => @Dto.LocationId)" TargetSelector="#tkbxLocationName" /></div></Template></FormItem>@code{async Task GetLocationItems(ReadEventArgs args){ DataSourceRequest newRequest = new DataSourceRequest() { Filters = new List<IFilterDescriptor>() }; if (RecordLoading) { args.Request.Filters.Clear(); newRequest.Filters.Add(new FilterDescriptor { Member = nameof(LocationDTO.Id), Operator = Telerik.DataSource.FilterOperator.IsEqualTo, MemberType = typeof(int), Value = Dto.LocationId }); } else { newRequest = GenerateLocationCustomFilterRequest(args.Request); if (Dto.CustomerId > 0) { newRequest.Filters.Add(new FilterDescriptor { Member = nameof(LocationDTO.CustomerId), Operator = Telerik.DataSource.FilterOperator.IsEqualTo, MemberType = typeof(int), Value = Dto.CustomerId }); newRequest.Skip = 0; //newRequest.PageSize = 100; } } if (RanderFromCustomer && CustomerId > 0) { newRequest.Filters.Add(new FilterDescriptor { Member = nameof(LocationDTO.CustomerId), Operator = Telerik.DataSource.FilterOperator.IsEqualTo, MemberType = typeof(int), Value = CustomerId }); } if (RanderFromLocation && LocationId > 0) { newRequest.Filters.Add(new FilterDescriptor { Member = nameof(LocationDTO.Id), Operator = Telerik.DataSource.FilterOperator.IsEqualTo, MemberType = typeof(int), Value = LocationId }); } var result = await _locationservice.GetAllForDropDownWithPaging(newRequest, Dto.BranchId); //newRequest.PageSize = result.Data.TotalItemCount; args.Data = result?.Data?.CurrentPageData; args.Total = result.Data.TotalItemCount;}}LocationService.cs
public async Task<Response<DataEnvelope<LocationDropdownDTO>>> GetAllForDropDownWithPaging(DataSourceRequest gridRequest, byte branchId){ try { HttpResponseMessage response = await _service.httpClient.PostAsync($"{API.Location}/{API.GetAllForDropDownWithPaging}/{branchId}", new StringContent(JsonConvert.SerializeObject(gridRequest), Encoding.UTF8, API.MediaType)); return await response.Content.ReadFromJsonAsync<Response<DataEnvelope<LocationDropdownDTO>>>(); } catch (System.Exception ex) { throw ex; }}LocationController.cs
public async Task<ActionResult<DataEnvelope<LocationDropdownDTO>>> GetAllForDropDownWithPaging([FromBody] DataSourceRequest gridRequest, byte branchId){ Response<List<LocationDropdownDTO>> result; DataEnvelope<LocationDropdownDTO> dataToReturn; try { result = _cacheService.GetData<Response<List<LocationDropdownDTO>>>(CacheConstant.AllLocationCache); if (result == null) { result = await _service.GetAllForDropDown(); DateTimeOffset expirationTime = DateTimeOffset.Now.AddMinutes(CacheConstant.CacheExpirationTime); _ = _cacheService.SetData<Response<List<LocationDropdownDTO>>>(CacheConstant.AllLocationCache, result, expirationTime); } IQueryable<LocationDropdownDTO> queriableData = result.Data. Where(x => x.BranchId == branchId).AsQueryable(); DataSourceResult processedData = await queriableData.ToDataSourceResultAsync(gridRequest); dataToReturn = new DataEnvelope<LocationDropdownDTO> { CurrentPageData = processedData.Data.Cast<LocationDropdownDTO>().ToList(), TotalItemCount = processedData.Total }; } catch (Exception ex) { throw ex; } return Ok(new Response<DataEnvelope<LocationDropdownDTO>> { Data = dataToReturn, Message = "SUCCESS" });}Please help me on this.