0

我使用 Gridview Devexpress 组件,对此有一点问题。我尝试描述我的问题。

我对列“格式”有不同的数据源,具体取决于列类型,在编辑模式下,它可以显示良好的数据源

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

但是,如果我保存它并希望在显示模式下显示选定的“格式”,我只会得到一个数据源,它是在 init 上的“格式”列上的声明,如代码中所示。

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

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

1 回答 1

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;
}
于 2015-01-11T21:37:01.797 回答