|
@@ -1008,6 +1008,8 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
|
|
|
|
|
|
#region Refresh / Reload
|
|
|
|
|
|
+ protected bool IsPaging { get; set; } = false;
|
|
|
+
|
|
|
protected abstract void Reload(
|
|
|
Filters<T> criteria, Columns<T> columns, ref SortOrder<T>? sort,
|
|
|
CancellationToken token, Action<CoreTable?, Exception?> action);
|
|
@@ -2163,36 +2165,60 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
|
|
|
reloadColumns.Add(column);
|
|
|
}
|
|
|
|
|
|
- var sort = LookupFactory.DefineSort<T>();
|
|
|
- Reload(filters, reloadColumns, ref sort, CancellationToken.None, (data, err) => Dispatcher.Invoke(() =>
|
|
|
+ CoreTable? data = null;
|
|
|
+
|
|
|
+ void LoadExport()
|
|
|
{
|
|
|
- if (data is not null)
|
|
|
- {
|
|
|
- var newData = new CoreTable();
|
|
|
- newData.LoadColumns(columns);
|
|
|
+ var newData = new CoreTable();
|
|
|
+ newData.LoadColumns(columns);
|
|
|
|
|
|
- FilterRows(data.Rows, newData, filter: row =>
|
|
|
+ FilterRows(data.Rows, newData, filter: row =>
|
|
|
+ {
|
|
|
+ foreach(var (_, predicate) in predicates)
|
|
|
{
|
|
|
- foreach(var (_, predicate) in predicates)
|
|
|
+ if (!predicate(row))
|
|
|
{
|
|
|
- if (!predicate(row))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ return false;
|
|
|
}
|
|
|
- return true;
|
|
|
- });
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
|
|
|
- var list = new List<Tuple<Type?, CoreTable>>() { new(typeof(T), newData) };
|
|
|
- list.AddRange(LoadExportTables(filters, otherColumns));
|
|
|
- DoExportTables(list);
|
|
|
+ var list = new List<Tuple<Type?, CoreTable>>() { new(typeof(T), newData) };
|
|
|
+ list.AddRange(LoadExportTables(filters, otherColumns));
|
|
|
+ DoExportTables(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ var sort = LookupFactory.DefineSort<T>();
|
|
|
+ Reload(filters, reloadColumns, ref sort, CancellationToken.None, (table, err) =>
|
|
|
+ {
|
|
|
+ if (table is not null)
|
|
|
+ {
|
|
|
+ if (table.Offset == 0 || data is null)
|
|
|
+ {
|
|
|
+ data = table;
|
|
|
+ if (!IsPaging)
|
|
|
+ {
|
|
|
+ Dispatcher.Invoke(LoadExport);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.AddPage(table);
|
|
|
+ if (!IsPaging)
|
|
|
+ {
|
|
|
+ Dispatcher.Invoke(LoadExport);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else if (err is not null)
|
|
|
{
|
|
|
- Logger.Send(LogType.Error, "", $"Error in export: {CoreUtils.FormatException(err)}");
|
|
|
- MessageBox.Show(err.Message);
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ MessageWindow.ShowError("Error in export.", err);
|
|
|
+ });
|
|
|
}
|
|
|
- }));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private void Export_Click(object sender, RoutedEventArgs e)
|