|
@@ -82,7 +82,7 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
|
|
|
ColumnsComponent = new DynamicGridCustomColumnsComponent<TEntity>(this, GetTag());
|
|
|
|
|
|
- MergeBtn = AddButton("Merge", Wpf.Resources.merge.AsBitmapImage(Color.White), DoMerge);
|
|
|
+ MergeBtn = AddButton("Merge", Wpf.Resources.merge.AsBitmapImage(Color.White), MergeClick);
|
|
|
}
|
|
|
protected override void DoReconfigure(DynamicGridOptions options)
|
|
|
{
|
|
@@ -587,15 +587,20 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
|
|
|
return grid.EditItems(new[] { item }, t => children.ContainsKey(t) ? children[t] : null, true);
|
|
|
}
|
|
|
|
|
|
- private bool DoMerge(Button arg1, CoreRow[] arg2)
|
|
|
+ private bool MergeClick(Button arg1, CoreRow[] rows)
|
|
|
{
|
|
|
- if (arg2 == null || arg2.Length <= 1)
|
|
|
+ if (rows == null || rows.Length <= 1)
|
|
|
return false;
|
|
|
- var targetid = arg2.Last().Get<TEntity, Guid>(x => x.ID);
|
|
|
- var target = arg2.Last().ToObject<TEntity>().ToString();
|
|
|
- var otherids = arg2.Select(r => r.Get<TEntity, Guid>(x => x.ID)).Where(x => x != targetid).ToArray();
|
|
|
- string[] others = arg2.Where(r => otherids.Contains(r.Get<Guid>("ID"))).Select(x => x.ToObject<TEntity>().ToString()!).ToArray();
|
|
|
- var rows = arg2.Length;
|
|
|
+ return DoMerge(rows);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected virtual bool DoMerge(CoreRow[] rows)
|
|
|
+ {
|
|
|
+ var targetid = rows.Last().Get<TEntity, Guid>(x => x.ID);
|
|
|
+ var target = rows.Last().ToObject<TEntity>().ToString();
|
|
|
+ var otherids = rows.Select(r => r.Get<TEntity, Guid>(x => x.ID)).Where(x => x != targetid).ToArray();
|
|
|
+ string[] others = rows.Where(r => otherids.Contains(r.Get<Guid>("ID"))).Select(x => x.ToObject<TEntity>().ToString()!).ToArray();
|
|
|
+ var nRows = rows.Length;
|
|
|
if (MessageBox.Show(
|
|
|
string.Format(
|
|
|
"This will merge the following items:\n\n- {0}\n\n into:\n\n- {1}\n\nAfter this, the items will be permanently removed.\nAre you sure you wish to do this?",
|