|
@@ -19,11 +19,12 @@ namespace comal.timesheets
|
|
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
|
|
public partial class MobileDataGrid : ContentView
|
|
|
{
|
|
|
+ public List<DataGridViewModelItem> Items { get; set; }
|
|
|
DataGridSaveType SaveType { get; set; }
|
|
|
+
|
|
|
public event DataGridOptionsSet OnOptionsSet;
|
|
|
bool bSearching = false;
|
|
|
- ObservableCollection<DataGridFilter> Filters = new ObservableCollection<DataGridFilter>();
|
|
|
- List<DataGridViewModelItem> Items = new List<DataGridViewModelItem>();
|
|
|
+ ObservableCollection<DataGridFilter> Filters = new ObservableCollection<DataGridFilter>();
|
|
|
List<DataGridViewModelItem> CurrentItems = new List<DataGridViewModelItem>();
|
|
|
PropertyInfo[] info = typeof(DataGridViewModelItem).GetProperties();
|
|
|
Dictionary<string, List<string>> FilterOptions = new Dictionary<string, List<string>>();
|
|
@@ -32,6 +33,7 @@ namespace comal.timesheets
|
|
|
public MobileDataGrid()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ Items = new List<DataGridViewModelItem>();
|
|
|
Filters.CollectionChanged += Filters_CollectionChanged;
|
|
|
}
|
|
|
|
|
@@ -46,7 +48,6 @@ namespace comal.timesheets
|
|
|
});
|
|
|
OnOptionsSet?.Invoke(type.Name, savetype);
|
|
|
SaveType = savetype;
|
|
|
- itemsListView.SelectionMode = savetype == DataGridSaveType.None ? ListViewSelectionMode.None : ListViewSelectionMode.Single;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -143,17 +144,18 @@ namespace comal.timesheets
|
|
|
private void Row_Tapped(object sender, EventArgs e)
|
|
|
{
|
|
|
var item = itemsListView.SelectedItem as DataGridViewModelItem;
|
|
|
- if (item != null)
|
|
|
+ if (item != null && SaveType != DataGridSaveType.None)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
- bool selected = item.IsSelected;
|
|
|
- var foundItem = Items.FirstOrDefault(x => x.ID == item.ID);
|
|
|
- foundItem.IsSelected = selected ? false : true;
|
|
|
-
|
|
|
- var currentListFoundItem = CurrentItems.FirstOrDefault(x => x.ID == item.ID);
|
|
|
- if (currentListFoundItem != null)
|
|
|
- currentListFoundItem.IsSelected = selected ? false : true;
|
|
|
+ switch (SaveType)
|
|
|
+ {
|
|
|
+ case DataGridSaveType.Single:
|
|
|
+ AddSelectionToLists(item);
|
|
|
+ UnselectOthers(item);
|
|
|
+ break;
|
|
|
+ case DataGridSaveType.Multiple:
|
|
|
+ AddSelectionToLists(item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
List<DataGridViewModelItem> list = new List<DataGridViewModelItem>();
|
|
|
foreach (var i in CurrentItems)
|
|
@@ -161,6 +163,37 @@ namespace comal.timesheets
|
|
|
Refresh(list);
|
|
|
}
|
|
|
|
|
|
+ private void UnselectOthers(DataGridViewModelItem item)
|
|
|
+ {
|
|
|
+ UnselectItems(item, Items);
|
|
|
+ UnselectItems(item, CurrentItems);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UnselectItems(DataGridViewModelItem item, List<DataGridViewModelItem> selectedlist)
|
|
|
+ {
|
|
|
+ var list = selectedlist.Where(x => x.IsSelected == true);
|
|
|
+ foreach (var foundItem in list)
|
|
|
+ {
|
|
|
+ if (foundItem.ID != item.ID)
|
|
|
+ foundItem.IsSelected = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddSelectionToLists(DataGridViewModelItem item)
|
|
|
+ {
|
|
|
+ bool selected = item.IsSelected;
|
|
|
+
|
|
|
+ AddSelectionToList(selected, Items, item.ID);
|
|
|
+ AddSelectionToList(selected, CurrentItems, item.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddSelectionToList(bool selected, List<DataGridViewModelItem> list, Guid ID)
|
|
|
+ {
|
|
|
+ var foundItem = list.FirstOrDefault(x => x.ID == ID);
|
|
|
+ if (foundItem != null)
|
|
|
+ foundItem.IsSelected = selected ? false : true;
|
|
|
+ }
|
|
|
+
|
|
|
private void SearchEnt_OnDataGridSearchEntryChanged(int columnnumber, string value, string colname)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(value))
|