Exemple #1
0
        public virtual ActionResult CheckBoxList(string propertyName, object id)
        {
            id = CorrectIdType(id);
            var propertyNameWithoutPrefix = RemovePrefix(propertyName);
            var propertyMetaData          = MetaData.GetProperties()
                                            .First(p => p.Name == propertyNameWithoutPrefix);
            var model = new ComboBoxVM();

            model.PropertyName = propertyName;
            var entity               = Repository.GetByPK(id);
            var m2MEntities          = entity.GetValue(propertyNameWithoutPrefix) as IEnumerable;
            var values               = new List <object>();
            var otherM2MType         = LinqToSqlUtils.GetOtherM2MEntityType(propertyMetaData.Info);
            var otherM2MPropertyInfo = LinqToSqlUtils.GetOtherM2MPropertyInfo(
                propertyMetaData.Info);

            foreach (var m2MEntity in m2MEntities)
            {
                values.Add(otherM2MPropertyInfo.GetValue(m2MEntity));
            }
            var source = ComboBoxSourceCreator.GetSource(otherM2MType);

            model.Source = SelectListUtil.GetSelectedListItems(propertyMetaData,
                                                               source, values);
            return(PartialView(Const.Common.FolderControls +
                               Controls.CheckBoxList, model));
        }
Exemple #2
0
        public virtual ActionResult FilterComboBox(string propertyName, object currentValue)
        {
            var propertyNameWithoutPrefix = RemovePrefix(propertyName);
            var propertyMetaData          = MetaData.GetProperties()
                                            .First(p => p.Name == propertyNameWithoutPrefix);
            var model = new ComboBoxVM();

            model.PropertyName = propertyName;
            var filterSource = ComboBoxSourceCreator
                               .GetFilterComboBoxSource(MetaData, propertyMetaData, currentValue);

            model.Source = SelectListUtil.GetSourceForFilter(propertyMetaData,
                                                             filterSource, MetaData.EntityType, currentValue);
            return(PartialView(Const.Common.FolderControls + Controls.Select, model));
        }
Exemple #3
0
        protected virtual List <object> GetValuesForRow(T item)
        {
            var list = new List <object>();

            foreach (var property in MetaData.GetProperties())
            {
                if (property.Control() == Controls.Hidden)
                {
                    continue;
                }
                var value = SelectListUtil.GetValueForProperty(property, item, Url);
                list.Add(value);
            }
            return(list);
        }
Exemple #4
0
        public virtual ActionResult Select(string propertyName, object currentValue,
                                           object id)
        {
            if (id == string.Empty)
            {
                id = null;
            }
            var propertyNameWithoutPrefix = RemovePrefix(propertyName);
            var propertyMetaData          = MetaData.GetProperties()
                                            .First(p => p.Name == propertyNameWithoutPrefix);
            var model = new ComboBoxVM();

            model.PropertyName = propertyName;
            currentValue       = ObjectUtils.SmartConvert(currentValue.NotNullString(),
                                                          propertyMetaData.Type);
            var comboBoxSource = ComboBoxSourceCreator.GetComboBoxSource(propertyMetaData,
                                                                         GetComboBoxFilter(propertyName, id));

            model.Source = SelectListUtil.GetSourceForComboBox(propertyMetaData,
                                                               currentValue, comboBoxSource);
            return(PartialView(Const.Common.FolderControls + Controls.Select, model));
        }