0

私はGridview Devexpressコンポーネントを使用していますが、ほとんど問題はありません。私の問題を説明してみます。

Typ 列に依存する "Format" 列の異なるデータ ソースがあります。編集モードでは、適切なデータ ソースが表示されます。

画像: http://www.imageshack.cz/images/2015/01/11/obr2.png

しかし、それを保存して、選択した「フォーマット」を表示モードで表示したい場合、ここのコードのように、init の列「フォーマット」で宣言されたデータソースを 1 つだけ取得します。

表示モードではデータソースが1つしかないため、列「Format」の悪い変数を見てください

画像: 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 に答える