Exemplo n.º 1
0
 protected override void ReadValueCore()
 {
     base.ReadValueCore();
     if (PropertyValue is XPBaseCollection)
     {
         ASPxCheckBoxList control = ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit ? Editor : InplaceViewModeEditor;
         if (control == null)
         {
             return;
         }
         control.SelectedIndexChanged -= new EventHandler(Control_SelectedIndexChanged);
         checkedItems = (XPBaseCollection)PropertyValue;
         XPCollection dataSource = new XPCollection(checkedItems.Session, MemberInfo.ListElementType);
         IModelClass  classInfo  = application.Model.BOModel.GetClass(MemberInfo.ListElementTypeInfo.Type);
         if (checkedItems.Sorting.Count > 0)
         {
             dataSource.Sorting = checkedItems.Sorting;
         }
         else if (!String.IsNullOrEmpty(classInfo.DefaultProperty))
         {
             dataSource.Sorting.Add(new SortProperty(classInfo.DefaultProperty, DevExpress.Xpo.DB.SortingDirection.Ascending));
         }
         control.DataSource = dataSource;
         control.TextField  = classInfo.DefaultProperty;
         control.ValueField = classInfo.KeyProperty;
         control.ValueType  = classInfo.TypeInfo.KeyMember.MemberType;
         control.DataBind();
         control.UnselectAll();
         foreach (object obj in checkedItems)
         {
             control.Items.FindByValue(objectSpace.GetKeyValue(obj)).Selected = true;
         }
         control.SelectedIndexChanged += new EventHandler(Control_SelectedIndexChanged);
     }
 }