Пример #1
0
        public override void ViewModelCreated(DynamicPropertyMetadata dynamicPropertyMetadata, IDictionary <string, object> controlParameters)
        {
            base.ViewModelCreated(dynamicPropertyMetadata, controlParameters);
            var dynamicForiegnKeyPropertyMetadata = (DynamicForiegnKeyPropertyMetadata)dynamicPropertyMetadata;

            string selectedValue = "";

            if (RouteValueDictionaryWrapper.ContainsKey(dynamicPropertyMetadata.PropertyName))
            {
                selectedValue = RouteValueDictionaryWrapper.GetValue(dynamicPropertyMetadata.PropertyName).ToString();
            }

            if (LabelText == PropertyName)
            {
                LabelText = dynamicForiegnKeyPropertyMetadata.ComplexEntityPropertyMetadata.PropertyName;
            }

            Type           = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.EntityType;
            DataTextField  = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.DefaultProperty.PropertyName;
            DataValueField = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.KeyProperty.PropertyName;
            if (controlParameters.ContainsKey("NullText"))
            {
                NullText = controlParameters["NullText"].ToString();
            }
            else
            {
                NullText = "Select Item";
            }
            SelectedValue = selectedValue;

            SelectList = _selectListItemManager.GetSelectListItems(Type, DataValueField, DataTextField, SelectedValue, NullText);
        }
        public void Build(DynamicPropertyMetadata dynamicPropertyMetadata, DynamicPropertyEditorViewModel dynamicPropertyViewModel, dynamic item)
        {
            var dynamicForiegnKeyPropertyMetadata = ((DynamicForiegnKeyPropertyMetadata)dynamicPropertyMetadata);
            var type           = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.EntityTypeFunction()();
            var dataTextField  = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.DefaultProperty().PropertyName();
            var dataValueField = dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.KeyProperty().PropertyName();
            var dynamicEditorDropDownViewModel = new DynamicEditorDropDownViewModel(dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.EntityTypeFunction()(), dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.DefaultProperty().PropertyName(), dynamicForiegnKeyPropertyMetadata.ComplexDynamicEntityMetadata.KeyProperty().PropertyName());
            var value = dynamicPropertyMetadata.GetValueFunction()(item);

            dynamicEditorDropDownViewModel.SelectListItems = _selectListItemManager.GetSelectListItems(type, dataValueField, dataTextField, value);

            dynamicPropertyViewModel.DynamicEditorDropDownViewModel = dynamicEditorDropDownViewModel;

            dynamicPropertyViewModel.DisplayName = dynamicForiegnKeyPropertyMetadata.ComplexEntityPropertyMetadata.PropertyName();
        }