Exemplo n.º 1
0
 public GridRowViewModel(IRecord record, DynamicGridViewModel gridViewModel)
     : base(gridViewModel.FormController, gridViewModel.OnlyValidate)
 {
     Record        = record;
     GridViewModel = gridViewModel;
     LoadFields();
     DeleteRowViewModel = new XrmButtonViewModel("Delete", DeleteRow, ApplicationController, description: "Delete");
     EditRowViewModel   = new XrmButtonViewModel("Edit", EditRow, ApplicationController, description: "Open For Editing");
 }
Exemplo n.º 2
0
        public static IEnumerable <GridRowViewModel> CreateGridRows(IEnumerable <IRecord> records,
                                                                    DynamicGridViewModel gridVm, bool isReadOnly = false)
        {
            var gridRows = new List <GridRowViewModel>();

            foreach (var record in records)
            {
                gridRows.Add(new GridRowViewModel(record, gridVm, isReadOnly: isReadOnly));
            }
            return(gridRows);
        }
        public static ObservableCollection <GridRowViewModel> LoadRows(IEnumerable <IRecord> records,
                                                                       DynamicGridViewModel gridVm, bool isReadOnly = false)
        {
            var gridRows = new ObservableCollection <GridRowViewModel>();

            foreach (var record in records)
            {
                gridRows.Add(new GridRowViewModel(record, gridVm, isReadOnly: isReadOnly));
            }

            return(gridRows);
        }
Exemplo n.º 4
0
 public GridRowViewModel(IRecord record, DynamicGridViewModel gridViewModel, bool isReadOnly = false)
     : base(gridViewModel.FormController, gridViewModel.OnlyValidate)
 {
     IsReadOnly    = isReadOnly;
     Record        = record;
     GridViewModel = gridViewModel;
     LoadFields();
     DeleteRowViewModel        = new XrmButtonViewModel("Remove", DeleteRow, ApplicationController, description: "Remove This Item");
     EditRowViewModel          = new XrmButtonViewModel("Open", EditRow, ApplicationController, description: "Open This Item");
     EditRowNewTabViewModel    = new XrmButtonViewModel("Open In New Tab", EditRowNewTab, ApplicationController, description: "Open This Item In New Tab");
     EditRowNewWindowViewModel = new XrmButtonViewModel("Open In New Window", EditRowNewTab, ApplicationController, description: "Open This Item In New Window");
     OpenWebViewModel          = new XrmButtonViewModel("Open In Browser", OpenWeb, ApplicationController, description: "Open This Item In Browser");
 }
Exemplo n.º 5
0
        public GetGridRecordsResponse GetGridRecords(bool ignorePages)
        {
            var query = GenerateQuery();

            if (!DynamicGridViewModel.HasPaging || ignorePages)
            {
                var records = DynamicGridViewModel.RecordService.RetreiveAll(query);
                return(new GetGridRecordsResponse(records));
            }
            else
            {
                return(DynamicGridViewModel.GetGridRecordPage(query));
            }
        }
Exemplo n.º 6
0
        public GetGridRecordsResponse GetGridRecords(bool ignorePages)
        {
            var view = DynamicGridViewModel.RecordService.GetView(DynamicGridViewModel.RecordType, DynamicGridViewModel.ViewType);

            if (!DynamicGridViewModel.HasPaging)
            {
                var records =
                    DynamicGridViewModel.RecordService.GetFirstX(DynamicGridViewModel.RecordType, -1, null, null,
                                                                 view.Sorts);
                return(new GetGridRecordsResponse(records));
            }
            else
            {
                return(DynamicGridViewModel.GetGridRecordPage(null, view.Sorts));
            }
        }
Exemplo n.º 7
0
 public ListViewModel(string recordType, IRecordService recordService, IApplicationController controller, Action <GridRowViewModel> editGridRow, Action addRow, IEnumerable <CustomGridFunction> customFunctions)
     : base(controller)
 {
     DynamicGridViewModel = new DynamicGridViewModel(ApplicationController)
     {
         EditRow        = editGridRow,
         AddRow         = addRow,
         PageSize       = StandardPageSize,
         ViewType       = ViewType.MainApplicationView,
         RecordService  = recordService,
         RecordType     = recordType,
         IsReadOnly     = true,
         FormController = new FormController(recordService, null, controller),
         GetGridRecords = GetGridRecords
     };
     DynamicGridViewModel.AddGridButtons(customFunctions);
     DynamicGridViewModel.ReloadGrid();
 }
Exemplo n.º 8
0
 public void QuickFind()
 {
     if (!IsQuickFind)
     {
         var anyNotValid = false;
         foreach (var condition in FilterConditions.Conditions)
         {
             if (!condition.Validate())
             {
                 anyNotValid = true;
             }
         }
         if (anyNotValid)
         {
             return;
         }
     }
     DynamicGridViewModel.ReloadGrid();
 }
Exemplo n.º 9
0
        public void RecreateGrid()
        {
            if (RecordType != null)
            {
                DynamicGridViewModel = new DynamicGridViewModel(ApplicationController)
                {
                    PageSize       = StandardPageSize,
                    ViewType       = ViewType.MainApplicationView,
                    RecordService  = RecordService,
                    RecordType     = RecordType,
                    IsReadOnly     = true,
                    FormController = new FormController(RecordService, null, ApplicationController),
                    GetGridRecords = GetGridRecords,
                    MultiSelect    = true,
                    GridLoaded     = false
                };
                var customFunctionList = new List <CustomGridFunction>()
                {
                    new CustomGridFunction("QUERY", "Run Query", QuickFind)
                };
                if (FormService != null)
                {
                    DynamicGridViewModel.EditRow = (g) =>
                    {
                        var formMetadata   = FormService.GetFormMetadata(RecordType, RecordService);
                        var formController = new FormController(this.RecordService, FormService, ApplicationController);
                        var selectedRow    = g;
                        if (selectedRow != null)
                        {
                            Action onSave = () =>
                            {
                                ClearChildForm();
                                DynamicGridViewModel.ReloadGrid();
                            };
                            var record = selectedRow.Record;

                            var newForm = new CreateOrUpdateViewModel(RecordService.Get(record.Type, record.Id), formController, onSave, ClearChildForm);
                            LoadChildForm(newForm);
                        }
                    };
                    DynamicGridViewModel.AddRow = () =>
                    {
                        var    formMetadata   = FormService.GetFormMetadata(RecordType, RecordService);
                        var    formController = new FormController(RecordService, FormService, ApplicationController);
                        Action onSave         = () =>
                        {
                            ClearChildForm();
                            DynamicGridViewModel.ReloadGrid();
                        };
                        var newForm = new CreateOrUpdateViewModel(RecordService.NewRecord(RecordType), formController, onSave, ClearChildForm, explicitIsCreate: true);
                        LoadChildForm(newForm);
                    };
                }
                customFunctionList.Add(new CustomGridFunction("CSV", "Download CSV", (g) => g.DownloadCsv(), (g) => g.GridRecords != null && g.GridRecords.Any()));

                if (CustomFunctions != null)
                {
                    foreach (var item in CustomFunctions)
                    {
                        customFunctionList.Add(item);
                    }
                }

                DynamicGridViewModel.AddGridButtons(customFunctionList);
                if (LoadInitially)
                {
                    DynamicGridViewModel.ReloadGrid();
                }

                RefreshConditionButtons();
            }
        }