-
Notifications
You must be signed in to change notification settings - Fork 36
Triggers
Jaroslav Surala edited this page Jan 12, 2020
·
2 revisions
FlexGrid support runtime changing of some properties.
You can manually invoke refresh of current page.
<button class="btn btn-primary" @onclick="@ReloadCurrentPage">Reload data</button>
async Task ReloadCurrentPage()
{
await dataAdapter.ReloadCurrentPage();
}
You can change your data adapter for Grid while runtime.
@inject LazyLoadedTableDataAdapter<WeatherForecast> forecastAdapter
<GridView DataAdapter="@dataAdapter"
LazyLoadingOptions="@options"
PageSize="10"
SaveOperationFinished="@ItemSavedOperationFinished"
DeleteOperationFinished="@ItemDeletedOperationFinished"
NewItemCreated="@ItemCreated">
</GridView>
<button class="btn btn-primary" @onclick="@ChangeDataAdapter">Change data adapter</button>
@code{
ITableDataAdapter dataAdapter;
protected override void OnInitialized()
{
base.OnInitialized();
dataAdapter = forecastAdapter;
}
async Task ChangeDataAdapter()
{
var forecast = await Http.GetJsonAsync<WeatherForecast[]>("api/SampleData/WeatherForecastsSimple");
dataAdapter = new CollectionTableDataAdapter<WeatherForecast>(forecast);
}
}
<GridView DataAdapter="@dataAdapter" PageSize="@pageSize"></GridView>
<button class="btn btn-primary" @onclick="@SetPageSize">Change page size</button>
async Task SetPageSize()
{
pageSize++;
}
<GridView DataAdapter="@dataAdapter"
LazyLoadingOptions="@options"
PageSize="10">
</GridView>
<button class="btn btn-primary" @onclick="@ChangeOptions">Change options</button>
void ChangeOptions()
{
options = new LazyLoadingOptions()
{
DataUri = "api/SampleData/WeatherForecasts",
PutDataUri = "api/SampleData/UpdateWeatherForecast",
DeleteUri = "api/SampleData/Delete/{Id}"
};
options.RequestParams.Add("test", "value");
}