我有一个填充了数据的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>
答案 0 :(得分: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>
答案 1 :(得分:0)
如果使用客户端事件隐藏列以防止回调,那会更好。 使用以下代码作为指南:
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
请注意,您还应该将一个客户端实例名称分配给要隐藏的列,以便您在javascript中访问它。希望这可以帮助! :)