DevExpress Gridview - 显示模式下列上的不同数据源

时间:2015-01-11 17:58:41

标签: c# asp.net-mvc gridview devexpress devexpress-mvc

我使用Gridview Devexpress组件,它没什么问题。我尝试描述我的问题。

我依赖于列Typ的“Format”列有不同的数据源,在编辑模式下它的ok显示良好的数据源

图片:http://www.imageshack.cz/images/2015/01/11/obr2.png

但是如果我保存它并希望show在显示模式下选择“Formát”,我只获得一个数据源,这是在init上的“Formát”列上的声明,如代码中所示。

在列“Formát”上看它的坏变量,因为在显示模式下我只有一个数据源

图片: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

1 个答案:

答案 0 :(得分: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;
}
相关问题