Skip to content

Commit

Permalink
fix(module: table): exception cause by reload data with state and the…
Browse files Browse the repository at this point in the history
… table has an ActionColumn
  • Loading branch information
ElderJames committed Sep 6, 2022
1 parent 9805945 commit 9517f19
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
12 changes: 4 additions & 8 deletions components/table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ public bool RemoteDataSource

private IList<SummaryRow> _summaryRows;

private IFieldColumn[] _fieldColumns;

private bool _hasInitialized;
private bool _waitingDataSourceReload;
private bool _waitingReloadAndInvokeChange;
Expand Down Expand Up @@ -230,8 +228,6 @@ private void OnColumnInitialized()
return;
}

_fieldColumns = ColumnContext.HeaderColumns.Where(x => x is IFieldColumn field && field.FieldName is not null).Cast<IFieldColumn>().ToArray();

ReloadAndInvokeChange();
_hasInitialized = true;
}
Expand Down Expand Up @@ -272,14 +268,14 @@ public void ReloadData(QueryModel queryModel)

foreach (var sorter in queryModel.SortModel)
{
var fieldColumn = _fieldColumns[sorter.ColumnIndex];
fieldColumn.SetSortModel(sorter);
var fieldColumn = ColumnContext.HeaderColumns[sorter.ColumnIndex] as IFieldColumn;
fieldColumn?.SetSortModel(sorter);
}

foreach (var filter in queryModel.FilterModel)
{
var fieldColumn = _fieldColumns[filter.ColumnIndex];
fieldColumn.SetFilterModel(filter);
var fieldColumn = ColumnContext.HeaderColumns[filter.ColumnIndex] as IFieldColumn;
fieldColumn?.SetFilterModel(filter);
}

this.ReloadAndInvokeChange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
<Button @onclick="SaveTableWithJson">SAVE JSON</Button>
<Button @onclick="LoadTableWithJson">LOAD JSON</Button>
<Button @onclick="ResetTable">RESET</Button>

<Table DataSource="data" OnChange="OnChange" TItem="Data" @ref="Table" >
<br />
<Table DataSource="data" OnChange="OnChange" TItem="Data" @ref="Table" Size="TableSize.Small">
<PropertyColumn
Property="c=>c.Number"
Sortable
Filterable />

<PropertyColumn
Property="c=>c.Id"
Sortable
Filterable />
<PropertyColumn
Property="c=>c.Name"
SorterCompare="@((a,b)=> string.Compare(a,b))"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
order: 32
order: 6.6
title:
en-US: Restore query state
zh-CN: 恢复筛选状态
zh-CN: 筛选状态
---

## zh-CN

任何带有“过滤器”、“排序”、“页面大小”和“页面索引”的筛选状态都可以保存,并可以在以后重新恢复 Table 的分页、排序和过滤器。
在调用 `ReloadData()` 时可以将包含 “分页”、“排序”、“过滤器” 等状态的 `QueryModel` 传递给 `Table` 恢复状态。
另外也可以调用 `ResetData()` 重置 `Table` 状态。

## en-US

Every table configuration with 'Filter', 'Sort', 'PageSize' and 'PageIndex' can be saved and later re-applied. Also applied sorting and filters can be reseted by one click.
Every table configuration with 'Filter', 'Sort', 'PageSize' and 'PageIndex' can be saved and later re-applied by `ReloadData()`.
Also applied sorting and filters can be reseted by `ResetData()`.

0 comments on commit 9517f19

Please sign in to comment.