CardViewClientSideEvents.FocusedCardChanged Property
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v18.2.dll
Declaration
[DefaultValue("")]
public string FocusedCardChanged { get; set; }
<DefaultValue("")>
Public Property FocusedCardChanged As String
Property Value
Type |
Default |
Description |
String |
String.Empty
|
A string that represents either the name of a JavaScript function or the entire JavaScript function code used to handle an event.
|
Example
This example demonstrates how to use the ASPxDataView control to show the detail ASPxCardView data.See also:T272616: ASPxCardView - How to display master-detail data using two ASPxCardView controls
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
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();
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v15.1, Version=15.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function FocusedCardChanged(s, e) {
dataview.PerformCallback(s.GetCardKey(s.GetFocusedCardIndex()));
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<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" VisibleIndex="0">
</dx:CardViewTextColumn>
<dx:CardViewTextColumn FieldName="CategoryName" VisibleIndex="1">
</dx:CardViewTextColumn>
<dx:CardViewTextColumn FieldName="Description" VisibleIndex="2">
</dx:CardViewTextColumn>
</Columns>
</dx:ASPxCardView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:AccessDataSource>
<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>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="CategoryID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v15.1, Version=15.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function FocusedCardChanged(s, e) {
dataview.PerformCallback(s.GetCardKey(s.GetFocusedCardIndex()));
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<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" VisibleIndex="0">
</dx:CardViewTextColumn>
<dx:CardViewTextColumn FieldName="CategoryName" VisibleIndex="1">
</dx:CardViewTextColumn>
<dx:CardViewTextColumn FieldName="Description" VisibleIndex="2">
</dx:CardViewTextColumn>
</Columns>
</dx:ASPxCardView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:AccessDataSource>
<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>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="CategoryID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DevExpress.Web
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub ASPxDataView1_CustomCallback(ByVal sender As Object, ByVal e As DevExpress.Web.CallbackEventArgsBase)
Session("CategoryID") = e.Parameter
AccessDataSource1.SelectParameters("CategoryID").DefaultValue = e.Parameter
TryCast(sender, ASPxDataView).DataBind()
End Sub
Protected Sub ASPxDataView1_Load(ByVal sender As Object, ByVal e As EventArgs)
If Session("CategoryID") Is Nothing Then
Return
End If
AccessDataSource1.SelectParameters("CategoryID").DefaultValue = Session("CategoryID").ToString()
TryCast(sender, ASPxDataView).DataBind()
End Sub
End Class
See Also