public void Load(RecordEntryViewModelBase recordForm, string subGridReference) { var parentForm = recordForm.ParentForm; if (parentForm != null) { parentForm.LoadingViewModel.IsLoading = true; } recordForm.DoOnAsynchThread(() => { try { var mainFormInContext = recordForm; if (recordForm is GridRowViewModel) { mainFormInContext = recordForm.ParentForm; } var closeFunction = new CustomGridFunction("RETURN", "Return", () => mainFormInContext.ClearChildForm()); var targetType = GetTargetType(recordForm, subGridReference); var selectedFunction = new CustomGridFunction("ADDSELECTED", "Add Selected", (g) => AddSelectedItems(g, recordForm, subGridReference) , visibleFunction: (g) => g.GridRecords != null && g.GridRecords.Any()); var addAllFunction = new CustomGridFunction("ADDALLRESULTS", "Add All Results", (g) => AddAllResults(g, recordForm, subGridReference) , visibleFunction: (g) => g.GridRecords != null && g.GridRecords.Any()); var childForm = new QueryViewModel(new[] { targetType }, GetQueryLookupService(recordForm, subGridReference), recordForm.ApplicationController, allowQuery: AllowQuery, loadInitially: !AllowQuery, closeFunction: closeFunction, customFunctions: new[] { selectedFunction, addAllFunction }, allowCrud: false); childForm.TypeAhead = TypeAhead; mainFormInContext.LoadChildForm(childForm); } catch (Exception ex) { recordForm.ApplicationController.ThrowException(ex); } finally { if (parentForm != null) { parentForm.LoadingViewModel.IsLoading = false; } } }); }
public void Load(RecordEntryViewModelBase recordForm, string subGridReference) { recordForm.LoadingViewModel.IsLoading = true; recordForm.DoOnAsynchThread(() => { try { var mainFormInContext = recordForm; if (recordForm is GridRowViewModel) { mainFormInContext = recordForm.ParentForm; } //okay i need to load a dialog //displaying a grid of the selectable options with a checkbox Action <IEnumerable <PicklistOption> > onSave = (selectedOptions) => { mainFormInContext.LoadingViewModel.IsLoading = true; try { AddSelectedItems(selectedOptions, recordForm, subGridReference); mainFormInContext.ClearChildForm(); } catch (Exception ex) { mainFormInContext.ApplicationController.ThrowException(ex); } finally { mainFormInContext.LoadingViewModel.IsLoading = false; } }; var picklistOptions = GetSelectionOptions(recordForm, subGridReference) .OrderBy(o => o.Value) .ToArray(); var initialSelected = GetInitialSelectedOptions(recordForm, subGridReference); var childForm = new MultiSelectDialogViewModel <PicklistOption>(picklistOptions, initialSelected, onSave, () => mainFormInContext.ClearChildForm(), mainFormInContext.ApplicationController, saveButtonLabel: "Add Selections", cancelButtonLabel: "Return"); mainFormInContext.LoadChildForm(childForm); } catch (Exception ex) { recordForm.ApplicationController.ThrowException(ex); } finally { recordForm.LoadingViewModel.IsLoading = false; } }); }
public override Action GetCustomFunction(RecordEntryViewModelBase recordForm, string subGridReference) { return(() => { recordForm.LoadingViewModel.IsLoading = true; recordForm.DoOnAsynchThread(() => { try { Thread.Sleep(100); Load(recordForm, subGridReference); } catch (Exception ex) { recordForm.ApplicationController.ThrowException(ex); recordForm.LoadingViewModel.IsLoading = false; } }); }); }