【问题标题】:DevExpress Gridview - different datasource on column in display modeDevExpress Gridview - 显示模式下列上的不同数据源
【发布时间】:2015-01-11 17:58:40
【问题描述】:

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

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

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 2015-10-07
      相关资源
      最近更新 更多