我有一个表单,表单有一个gridcontrol然后当我单击列选择器时,我将添加一个任何列添加列将删除gridcontrol当我关闭表单最后我不想丢失添加的列我希望我可以解释我想做什么,谢谢你的一切。
答案 0 :(得分:0)
请按照此示例自定义列:
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="CustomersDataSource"
KeyFieldName="CustomerID" Width="100%">
<Columns>
<dx:GridViewDataColumn FieldName="ContactName" VisibleIndex="0" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="CompanyName" VisibleIndex="1" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="City" VisibleIndex="2" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="Region" Visible="false" ShowInCustomizationForm="true" />
<dx:GridViewDataColumn FieldName="Country" VisibleIndex="3" ShowInCustomizationForm="true" />
</Columns>
<Templates>
<PagerBar>
<table width="100%">
<tr>
<td style="width: 50%">
<dx:ASPxGridViewTemplateReplacement ID="Pager" runat="server" ReplacementType="Pager" />
</td>
<td align="right">
<dx:ASPxButton ID="btnCustomizationWindow" runat="server" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
AutoPostBack="False" Text="Show/Hide Columns" Width="150px" ClientInstanceName="btnCustomizationWindow"
CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
<ClientSideEvents Click="btnCustomizationWindow_Click" />
</dx:ASPxButton>
</td>
</tr>
</table>
</PagerBar>
</Templates>
<Settings ShowGroupPanel="True" />
<SettingsLoadingPanel Mode="ShowOnStatusBar" />
<SettingsBehavior EnableCustomizationWindow="true" />
<SettingsCookies CookiesID="CookiesV1" Enabled="True" StoreColumnsVisiblePosition="true"
StoreColumnsWidth="true" StoreFiltering="False" StoreGroupingAndSorting="False"
StorePaging="False" /><%--This will store the column position and visibility--%>
</dx:ASPxGridView>
脚本:
<script type="text/javascript">
function btnCustomizationWindow_Click(s, e) {
if(grid.IsCustomizationWindowVisible())
grid.HideCustomizationWindow();
else
grid.ShowCustomizationWindow();
}
</script>
注意:
如果您希望隐藏某些列以进行自定义,请设置属性:
ShowInCustomizationForm="false"
希望这有帮助。