开发者

Devexpress: Add Clear All Button in ASPxGridLookup

开发者 https://www.devze.com 2023-03-25 10:26 出处:网络
I have a ASPxGridLookup like this; <dx:ASPxGridLookup ID=\"GridLookup\" runat=\"server\" Text=\'<%# Bind(\"AKTOR\") %>\'

I have a ASPxGridLookup like this;

<dx:ASPxGridLookup ID="GridLookup" runat="server" Text='<%# Bind("AKTOR") %>'
                        ClientInstanceName="gridLookup" DataSourceID="SqlDataSource3" 
                        KeyFieldName开发者_JAVA技巧="KOD" MultiTextSeparator=";" SelectionMode="Multiple" 
                        TextFormatString="{0}">
                        <GridViewProperties>
                            <SettingsPager PageSize="20" />
                        </GridViewProperties>
                        <Columns>
                            <dx:GridViewCommandColumn ShowSelectCheckbox="True" />
                            <dx:GridViewDataColumn FieldName="KOD" />
                            <dx:GridViewDataColumn CellStyle-Wrap="False" FieldName="ACIKLAMA" />
                        </Columns>
                    </dx:ASPxGridLookup>

Looks like that;

Devexpress: Add Clear All Button in ASPxGridLookup

I want to add Clear All button in this control. How can I do that?

NOTE: Like Close button in this example.


The example is based on a different product. You might want to use the DropDownEditor too. You should be able to place a grid view in it and use the client-side functionality to achieve what you want. Maybe a list box is sufficient, too. The DropDownEditor allows for a template with a complex arrangement of other controls.

[Edit 1]

So you could do something like this:

<dx:ASPxDropDownEdit ClientInstanceName="checkComboBox" ID="ASPxDropDownEdit1" SkinID="CheckComboBox" Width="210px" runat="server" EnableAnimation="False">
    <DropDownWindowStyle BackColor="#EDEDED" />
    <DropDownWindowTemplate>
        <dx:ASPxGridLookup ID="GridLookup" runat="server" Text='<%# Bind("AKTOR") %>'
                    ClientInstanceName="gridLookup" DataSourceID="SqlDataSource3" 
                    KeyFieldName="KOD" MultiTextSeparator=";" SelectionMode="Multiple" 
                    TextFormatString="{0}">
                    <GridViewProperties>
                        <SettingsPager PageSize="20" />
                    </GridViewProperties>
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" />
                        <dx:GridViewDataColumn FieldName="KOD" />
                        <dx:GridViewDataColumn CellStyle-Wrap="False" FieldName="ACIKLAMA" />
                    </Columns>
        </dx:ASPxGridLookup>
        <dx:ASPxButton ID="btnClear" runat="server" Text="Clear" AutoPostBack="False" />
    </DropDownWindowTemplate>
</dx:DropDownEdit>

That wraps a grid in the DropDownEdit, so you can actually do anything you want with that grid. The button could be used to trigger the desired action. You then should decide whether to achieve that using client side script or on the server side. But that's up to you.

Alternative

You might want to use the footer template.

<dx:ASPxGridView ID="ASPxGridView1" runat="server" Settings-ShowFooter="true">
    <Templates>
        <FooterRow>
            Hallo !
        </FooterRow>
    </Templates>
</dx:ASPxGridView>

You can put in there whatever you want, so feel free.


You can create a button and inside its click event, clear the ASPxGridLookup :

FronEnd Button:

  <dx:ASPxButton ID="btnClearAll" runat="server" Text="ClearAll" ClientInstanceName="btnClearAll" AutoPostBack="true" OnClick="btnClearAll_Click" ></dx:ASPxButton>

BackEnd Button OnClick Event:

 Protected Sub btnUpdatePreview_Click(sender As Object, e As EventArgs)
    GridLookup.GridView.Selection.UnselectAll() End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消