0

我有一个填充了数据的gridview,并且基于Chekbox 选择我想在editform 上隐藏一个字段。任何人都可以请指导,在客户端或服务器端代码隐藏列会更好吗?,请在我们选择复选框时找到以下代码供您参考(以下是 devexpress Grid 中的 4 列(4 个字段))那么其中一列(下拉)应该是隐藏的。)。

<dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="1"  Caption="Name">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Email" VisibleIndex="2"  Caption="Email">
 </dx:GridViewDataTextColumn>
<dx:GridViewDataCheckColumn FieldName="IsGraduate" VisibleIndex="3" Caption="Is Graduate ">
</dx:GridViewDataCheckColumn>
<dx:GridViewDataComboBoxColumn Caption="Degree" FieldName="Degree" 
 ShowInCustomizationForm="True" VisibleIndex="4">
<PropertiesComboBox DataSourceID="DegreeDataSource" TextField="Degree"  ValueField="Id">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
4

2 回答 2

0

It would be better if you hide the column by using client side events to prevent callbacks. Use the following codes as your guide:

    Protected Sub dgView_001_CellEditorInitialize(sender As Object, e As DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs) Handles dgView_001.CellEditorInitialize

    If e.Column.FieldName = "IsGraduate" Then

        Dim chk As DevExpress.Web.ASPxEditors.ASPxCheckBox = New DevExpress.Web.ASPxEditors.ASPxCheckBox()

        chk = TryCast(e.Editor, DevExpress.Web.ASPxEditors.ASPxCheckBox)

        chk.ClientInstanceName = "chkIsGraduate"

        chk.ClientSideEvents.CheckedChanged = "function(s, e){ //if checked = true, hide column you want to hide }"

   ElseIf e.Column.FieldName = "Degree" Then

        Dim cmb As DevExpress.Web.ASPxEditors.ASPxComboBox = New DevExpress.Web.ASPxEditors.ASPxComboBox()

        cmb = TryCast(e.Editor, DevExpress.Web.ASPxEditors.ASPxComboBox)

        cmb.ClientInstanceName = "cmbDegree"

   End If

   End Sub

Take note that you should also assign a client instance name to the column you want to hide for you to access it in javascript. Hope this helps! :)

于 2014-01-23T01:20:17.030 回答
0

您是否尝试对必要的列使用 EditFormSetting 可见性?看下面的例子

        <dx:GridViewDataComboBoxColumn FieldName="color" Caption="#" VisibleIndex="2" ReadOnly="True"
            Width="25px">
            <HeaderStyle HorizontalAlign="Center" />
            <PropertiesComboBox DataSourceID="ColoredStatusSource" TextField="name" ValueField="id"
                EnableSynchronization="False" IncrementalFilteringMode="Contains" ValueType="System.Int32">
            </PropertiesComboBox>
            <EditFormSettings Visible="False" />
        </dx:GridViewDataComboBoxColumn>
于 2014-01-22T03:35:24.003 回答