예제 #1
0
 public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
 {
     try
     {
         cmbCommon = new RadComboBox();
         if (!dataItem.IsNullOrEmpty())
         {
             PropertyInfo property = null;
             object       oObject  = dataItem;
             if (!DieuKienDataMember.IsNullOrEmptyOrSpace())
             {
                 foreach (string str in DieuKienDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         DieuKien = property.GetValue(oObject, null).ToString();
                         oObject  = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!sMaLoaiDM.Equals(""))
             {
                 lstComboBox = new List <AutoCompleteEntry>();
                 KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sMaLoaiDM);
             }
             if (!GiaTriDataMember.IsNullOrEmptyOrSpace())
             {
                 oObject = dataItem;
                 foreach (string str in GiaTriDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         GiaTri  = property.GetValue(oObject, null).IsNullOrEmpty() ? "" : property.GetValue(oObject, null).ToString();
                         oObject = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!GiaTri.IsNullOrEmptyOrSpace())
             {
                 cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(GiaTri)));
             }
             else
             {
                 cmbCommon.SelectedIndex = -1;
             }
         }
         cmbCommon.Tag               = lstComboBox;
         cmbCommon.IsEnabled         = true;
         cmbCommon.SelectionChanged += new SelectionChangedEventHandler(cmbCommon_SelectionChanged);
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     cellEdit = cell;
     return(cmbCommon as FrameworkElement);
 }
        public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            try
            {
                cmbCommon = new RadComboBox();
                if (lstComboBox != null || lstComboBox.Count > 0)
                {
                    new AutoComboBox().GenAutoComboBox(ref lstComboBox, ref cmbCommon, null, null, giaTri);
                }
                else
                {
                    if (!dataItem.IsNullOrEmpty())
                    {
                        PropertyInfo property = null;
                        if (!DieuKienDataMember.IsNullOrEmptyOrSpace())
                        {
                            property = dataItem.GetType().GetProperty(DieuKienDataMember);
                            if (property != null)
                            {
                                DieuKien = property.GetValue(dataItem, null).ToString();
                            }
                        }
                        property = dataItem.GetType().GetProperty(GiaTriDataMember);
                        if (property != null)
                        {
                            GiaTri      = property.GetValue(dataItem, null).ToString();
                            lstComboBox = new List <AutoCompleteEntry>();

                            List <string> lstDieuKien = new List <string>();
                            lstDieuKien.Add(DieuKien.ToString());
                            if (!sTruyVan.Equals(""))
                            {
                                KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sTruyVan, lstDieuKien);
                            }
                            cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(GiaTri)));
                            cmbCommon.Tag           = lstComboBox;
                        }
                    }
                }
                cmbCommon.IsEnabled         = true;
                cmbCommon.IsEditable        = true;
                cmbCommon.SelectionChanged += new SelectionChangedEventHandler(cmbCommon_SelectionChanged);
            }
            catch (Exception ex)
            {
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            cellEdit = cell;
            return(cmbCommon as FrameworkElement);
        }
예제 #3
0
 public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
 {
     try
     {
         cmbCommon = new RadComboBox();
         if (!dataItem.IsNullOrEmpty())
         {
             PropertyInfo property = null;
             object       oObject  = dataItem;
             if (!DieuKienDataMember.IsNullOrEmptyOrSpace())
             {
                 foreach (string str in DieuKienDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         DieuKien = property.GetValue(oObject, null).ToString();
                         oObject  = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!sTruyVan.Equals(""))
             {
                 List <string> lstDieuKien = new List <string>();
                 lstDieuKien.Add(DieuKien.ToString());
                 lstComboBox = new List <AutoCompleteEntry>();
                 KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sTruyVan, lstDieuKien);
             }
             if (!GiaTriDataMember.IsNullOrEmptyOrSpace())
             {
                 this.SetBinding(GiaTriProperty, CreateValueBinding(dataItem));
             }
             if (!GiaTri.IsNullOrEmptyOrSpace())
             {
                 cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(GiaTri)));
             }
             else
             {
                 cmbCommon.SelectedIndex = -1;
             }
         }
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     cmbCommon.IsEnabled = false;
     return(cmbCommon);
 }