DevExpress 网格视图 - 显示模式下列上的不同数据源

本文关键字:数据源 视图 网格 显示 模式 DevExpress | 更新日期: 2023-09-27 18:37:03

我使用Gridview Devexpress组件,它几乎没有问题。我尝试描述我的问题。

我有依赖于 Typ 列的"格式"列的不同数据源,在编辑模式下,它可以显示良好的数据源

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

但是,如果我保存它并希望在显示模式下显示选定的"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

DevExpress 网格视图 - 显示模式下列上的不同数据源

使用 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;
}