We're using an SfGrid with an SfDataManager to load records from an OData endpoint. This is on a page which contains several inputs, whose values we use to add clauses to the OData query.
We would like a way to prevent the grid from loading any data when it is first initialized - we want to defer data loading until the user has supplied values to the inputs and clicked a "Search" button. Is there any property or method on SfGrid or SfDataManager which we can use to temporarily prevent it from retrieving records?
Hi Austin,
We reviewed your query and it seems that you want to prevent the SfGrid from
loading data during initialization and instead delay the data loading until the
user provides input and clicks the "Search" button. To achieve this,
we recommend using the Query property of the SfGrid. Please refer to the code
snippet and sample below for more details.
|
<SfGrid @ref="Grid" TValue="Order" AllowPaging="true" AllowFiltering=true Query="RemoteDataQuery" AllowGrouping=true Toolbar="@ToolbarItems"> <GridPageSettings PageSize="50" />
</SfGrid>
@code { public SfGrid<Order> Grid; public SfDataManager DataManager; public static SfDataManager DataManagerRef { get; set; } public Query RemoteDataQuery = new Query();
int searchval;
private void ValueChangeHandler(ChangedEventArgs args) { searchval = Convert.ToInt32(args.Value); } public void Value() { RemoteDataQuery = new Query().Where("ParentId", "equal", searchval); Grid.Refresh(); }
public class NewODataClass : ODataV4Adaptor {
public NewODataClass(DataManager dm) : base(dm) {
} public override object ProcessQuery(DataManagerRequest queries) {
RequestOptions ActualReturnValue = (RequestOptions)(base.ProcessQuery(queries));
return ActualReturnValue;
} public override async Task<object> ProcessResponse<T>(object data, DataManagerRequest queries) { HttpResponseMessage responseval = data as HttpResponseMessage;
if (queries.Where != null) { var ActualReturnValue = await base.ProcessResponse<T>(data, queries); return ActualReturnValue; } else { return null; }
} } |
Kindly get back to us if you have further queries.
Regards,
Naveen
Thanks very much! that has resolved the issue.
Thanks for the update,
We are happy to hear that the provided information was helpful. We are closing the forum now.