public EnumerableFieldViewModel(string fieldName, string label, RecordEntryViewModelBase recordForm, string linkedRecordType) : base(fieldName, label, recordForm) { if (recordForm is RecordEntryFormViewModel) { LinkedRecordType = linkedRecordType; RecordForm = (RecordEntryFormViewModel)recordForm; DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = RecordForm.GridPageSize, DisplayTotalCount = RecordForm.GridPageSize > 0, GetTotalCount = () => GetGridRecords(true).Records.Count(), ViewType = ViewType.AssociatedView, DeleteRow = !recordForm.IsReadOnly && FormService.AllowDelete(ReferenceName, GetRecordType()) ? RemoveRow : (Action <GridRowViewModel>)null, EditRow = FormService.AllowGridOpen(ReferenceName, RecordForm) ? EditRow : (Action <GridRowViewModel>)null, AddRow = !recordForm.IsReadOnly && FormService.AllowAddNew(ReferenceName, GetRecordType()) ? AddRow : (Action)null, AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel), ExpandGrid = FormService.AllowGridFullScreen(FieldName) ? LoadGridEditDialog : (Action)null, IsReadOnly = !FormService.AllowGridFieldEditEdit(FieldName) || recordForm.IsReadOnly, ParentForm = recordForm, ReferenceName = ReferenceName, RecordType = linkedRecordType, RecordService = recordForm.RecordService, GetGridRecords = GetGridRecords, LoadRecordsAsync = true, FormController = recordForm.FormController, OnReloading = () => { _isLoaded = false; }, LoadedCallback = () => { _isLoaded = true; RecordForm.OnSectionLoaded(); }, OnlyValidate = recordForm.OnlyValidate, MaxHeight = 600, LoadDialog = (d) => { RecordEntryViewModel.LoadChildForm(d); }, RemoveParentDialog = () => { RecordEntryViewModel.ClearChildForms(); } }; DynamicGridViewModel.AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); DynamicGridViewModel.ExpandGrid = FormService.AllowGridFullScreen(FieldName) ? LoadGridEditDialog : (Action)null; } else { var bulkAddFunction = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); if (bulkAddFunction != null) { BulkAddButton = new XrmButtonViewModel("BULKADD", "BULK ADD", bulkAddFunction, ApplicationController); } EditAction = !RecordEntryViewModel.IsReadOnly && FormService.AllowNestedGridEdit(RecordEntryViewModel.ParentFormReference, FieldName) ? LoadGridEditDialog : (Action)null; } }
public EnumerableFieldViewModel(string fieldName, string label, RecordEntryViewModelBase recordForm, string linkedRecordType) : base(fieldName, label, recordForm) { if (recordForm is RecordEntryFormViewModel) { RecordForm = (RecordEntryFormViewModel)recordForm; LinkedRecordType = linkedRecordType; DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = RecordForm.GridPageSize, ViewType = ViewType.AssociatedView, DeleteRow = !recordForm.IsReadOnly && FormService.AllowDelete(ReferenceName, GetRecordType()) ? RemoveRow :(Action <GridRowViewModel>)null, EditRow = EditRow, AddRow = !recordForm.IsReadOnly && FormService.AllowAddNew(ReferenceName, GetRecordType()) ? AddRow : (Action)null, AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel), IsReadOnly = recordForm.IsReadOnly, ParentForm = recordForm, ReferenceName = ReferenceName, RecordType = linkedRecordType, RecordService = recordForm.RecordService, GetGridRecords = GetGridRecords, LoadRecordsAsync = true, FormController = recordForm.FormController, OnReloading = () => { _isLoaded = false; }, LoadedCallback = () => { _isLoaded = true; RecordForm.OnSectionLoaded(); }, OnlyValidate = recordForm.OnlyValidate, MaxHeight = 600, LoadDialog = (d) => { RecordEntryViewModel.LoadChildForm(d); } }; DynamicGridViewModel.AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); } else { var bulkAddFunction = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); if (bulkAddFunction != null) { BulkAddButton = new XrmButtonViewModel("BULKADD", "BULK ADD", bulkAddFunction, ApplicationController); } } }