Skip to main content

ASPxClientCardView.GetCardKey(visibleIndex) Method

Returns the key value of the specified card.

Declaration

GetCardKey(
    visibleIndex: number
): string

Parameters

Name Type Description
visibleIndex number

The card’s visible index.

Returns

Type Description
string

A string representing the specified card’s key value. If the index passed via the visibleIndex parameter is wrong, or the ASPxGridBase.KeyFieldName property is not set, null is returned.

Remarks

Note

If multiple key fields are set using the grid’s ASPxGridBase.KeyFieldName property, a specific service vertical bar symbol (the symbol |) is used to separate key field values in the string returned by the GetCardKey method.

Example

The example below demonstrates how to show ASPxCardView’s detail data.

function FocusedCardChanged(s, e) {
    dataview.PerformCallback(s.GetCardKey(s.GetFocusedCardIndex()));
}
<dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource2"
    KeyFieldName="CategoryID" ClientInstanceName="cardview">
    <SettingsBehavior AllowFocusedCard="True" />
    <ClientSideEvents FocusedCardChanged="FocusedCardChanged" />
    <Columns>
        <dx:CardViewTextColumn FieldName="CategoryID" ReadOnly="True" />
        <dx:CardViewTextColumn FieldName="CategoryName" />
        <dx:CardViewTextColumn FieldName="Description" />
    </Columns>
</dx:ASPxCardView>

<dx:ASPxDataView ID="ASPxDataView1" runat="server" SettingsTableLayout-ColumnCount="1" DataSourceID="AccessDataSource1"
        SettingsTableLayout-RowsPerPage="1" ClientInstanceName="dataview" OnCustomCallback="ASPxDataView1_CustomCallback"
    OnLoad="ASPxDataView1_Load">
    <ItemTemplate>
        <b>ProductID</b>:
        <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
        <br />
        <b>ProductName</b>:
        <asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("ProductName") %>' />
        <br />
        <b>CategoryID</b>:
        <asp:Label ID="CategoryIDLabel" runat="server" Text='<%# Eval("CategoryID") %>' />
        <br />
    </ItemTemplate>
</dx:ASPxDataView>

protected void ASPxDataView1_CustomCallback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
    Session["CategoryID"] = e.Parameter;
    AccessDataSource1.SelectParameters["CategoryID"].DefaultValue = e.Parameter;
    (sender as ASPxDataView).DataBind();
}
protected void ASPxDataView1_Load(object sender, EventArgs e) {
    if (Session["CategoryID"] == null) return;
    AccessDataSource1.SelectParameters["CategoryID"].DefaultValue = Session["CategoryID"].ToString();
    (sender as ASPxDataView).DataBind();
}
See Also