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);
 }
Exemple #2
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);
 }