2015-01-11 3 views
0

Gridview Devexpress 구성 요소와 함께 작동하는데 문제가 거의 없습니다. 나는 나의 문제를 묘사하려고 노력한다.DevExpress Gridview - 디스플레이 모드에서 열의 다른 데이터 소스

나는 편집 모드의 확인은 우수한 데이터 소스에서 열 "형식"열 통상에 따라, 대한 diffedent 데이터 소스를

이미지 : http://www.imageshack.cz/images/2015/01/11/obr2.png

내가 그것을 저장하고 싶다면 보여 선택 "형식 "디스플레이 모드에서, 나는 하나의 데이터 소스를 얻었는데,이 코드는 init의"Form "열에 선언되어있다. 때문에 디스플레이 모드에서의 나쁜 변수 열 "형식"에

봐 내가 하나의 데이터 소스를 가지고

이미지 : http://www.imageshack.cz/images/2015/01/11/obr3.png

settings.Columns.Add(column => 
      { 
       column.FieldName = "FormatType"; 
       column.Caption = Resources.FormatType; 

       column.ColumnType = MVCxGridViewColumnType.ComboBox; 
       var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties; 
       comboBoxProperties.DataSource = WebApp.Helpers.CodebooksHelper.GetItemData(1); 
       comboBoxProperties.TextField = "Title"; 
       comboBoxProperties.ValueField = "ItemID"; 
       comboBoxProperties.ValueType = typeof(int); 
       comboBoxProperties.IncrementalFilteringMode =IncrementalFilteringMode.StartsWith; 
       comboBoxProperties.DropDownStyle = DropDownStyle.DropDownList; 
      }); 

내가 같이 디스플레이 모드에서 컬럼에 데이터 소스를 선언 할 수있는 무언가를, 존재 편집 모드?

settings.CellEditorInitialize 

답변

0

ASPxGridView.CustomColumnDisplayText 이벤트를 사용하십시오.

protected void ASPxGridView2_CustomColumnDisplayText(object sender, 
    DevExpress.Web.ASPxGridViewColumnDisplayTextEventArgs e) { 
    if (e.Column.FieldName != "FormatType") return; 
    e.DisplayText = WebApp.Helpers.CodebooksHelper.GetItemData(1).First(item => item.ItemID == (int)e.Value).Title; 
} 

settings.CustomColumnDisplayText += (sender, e) => { 
     if (e.Column.FieldName != "FormatType") return; 
     e.DisplayText = WebApp.Helpers.CodebooksHelper.GetItemData(1).First(item => item.ItemID == (int)e.Value).Title; 
} 
+0

감사합니다. 'CustomColumnDisplayText' 도움이되었습니다. :) –