|
|
@@ -346,17 +346,6 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
DoChanged();
|
|
|
}
|
|
|
|
|
|
- private object GetPropertyValue(Expression member, object obj)
|
|
|
- {
|
|
|
- var objectMember = Expression.Convert(member, typeof(object));
|
|
|
-
|
|
|
- var getterLambda = Expression.Lambda<Func<object>>(objectMember);
|
|
|
-
|
|
|
- var getter = getterLambda.Compile();
|
|
|
-
|
|
|
- return getter();
|
|
|
- }
|
|
|
-
|
|
|
protected override void ObjectToRow(TEntity obj, CoreRow row)
|
|
|
{
|
|
|
foreach (var column in Data.Columns)
|
|
|
@@ -369,6 +358,21 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Update the <paramref name="row"/> by reloading the data from the database.
|
|
|
+ /// </summary>
|
|
|
+ public void UpdateRow(CoreRow row, bool invalidate = true)
|
|
|
+ {
|
|
|
+ var refreshedEntity = Client.Query(
|
|
|
+ GetRowFilter(row),
|
|
|
+ DataColumns())
|
|
|
+ .ToObjects<TEntity>().FirstOrDefault();
|
|
|
+ if(refreshedEntity is not null)
|
|
|
+ {
|
|
|
+ UpdateRow(row, refreshedEntity, invalidateRow: invalidate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public override void LoadEditorButtons(TEntity item, DynamicEditorButtons buttons)
|
|
|
{
|
|
|
base.LoadEditorButtons(item, buttons);
|
|
|
@@ -548,7 +552,7 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
}
|
|
|
|
|
|
var grid = new DynamicDataGrid<TEntity>();
|
|
|
- return grid.EditItems(new[] { item }, t => children.ContainsKey(t) ? children[t] : null, true);
|
|
|
+ return grid.EditItems([item], t => children.TryGetValue(t, out CoreTable? value) ? value : null, true);
|
|
|
}
|
|
|
|
|
|
private bool MergeClick(Button arg1, CoreRow[] rows)
|
|
|
@@ -643,7 +647,7 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
|
|
|
protected override IEnumerable<TEntity> LoadDuplicatorItems(CoreRow[] rows)
|
|
|
{
|
|
|
- return rows.Select(x => x.ToObject<TEntity>());
|
|
|
+ return rows.ToObjects<TEntity>();
|
|
|
}
|
|
|
|
|
|
protected override bool BeforeCopy(IList<TEntity> items)
|
|
|
@@ -659,38 +663,6 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- protected override void CustomiseExportFilters(Filters<TEntity> filters, CoreRow[] visiblerows)
|
|
|
- {
|
|
|
- base.CustomiseExportFilters(filters, visiblerows);
|
|
|
-
|
|
|
- /*if (IsEntity)
|
|
|
- {
|
|
|
- var ids = visiblerows.Select(r => r.Get<TEntity, Guid>(c => c.ID)).ToArray();
|
|
|
- filters.Add(Filter<TEntity>.Where(x => x.ID).InList(ids));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Filter<TEntity>? filter = null;
|
|
|
-
|
|
|
- foreach (var row in visiblerows)
|
|
|
- {
|
|
|
- var rowFilter = GetRowFilter(row);
|
|
|
- if(rowFilter is not null)
|
|
|
- {
|
|
|
- if (filter is null)
|
|
|
- {
|
|
|
- filter = rowFilter;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- filter.Or(rowFilter);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- filters.Add(filter);
|
|
|
- }*/
|
|
|
- }
|
|
|
-
|
|
|
protected override IEnumerable<Tuple<Type?, CoreTable>> LoadExportTables(Filters<TEntity> filter, IEnumerable<Tuple<Type, IColumns>> tableColumns)
|
|
|
{
|
|
|
var queries = new Dictionary<string, IQueryDef>();
|
|
|
@@ -719,9 +691,11 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
|
|
|
if (property != null)
|
|
|
{
|
|
|
- var subQuery = new SubQuery<TEntity>();
|
|
|
- subQuery.Filter = filter.Combine();
|
|
|
- subQuery.Column = new Column<TEntity>(x => x.ID);
|
|
|
+ var subQuery = new SubQuery<TEntity>
|
|
|
+ {
|
|
|
+ Filter = filter.Combine(),
|
|
|
+ Column = new Column<TEntity>(x => x.ID)
|
|
|
+ };
|
|
|
|
|
|
queryFilter = (Activator.CreateInstance(typeof(Filter<>).MakeGenericType(tableType)) as IFilter)!;
|
|
|
queryFilter.Property = property.Name + ".ID";
|