ASPxClientSpinEdit.NumberChanged Event
Occurs on the client side when the editor’s value is altered in any way.
Declaration
NumberChanged: ASPxClientEvent<ASPxClientProcessingModeEventHandler<ASPxClientSpinEdit>>
Event Data
Property |
Description |
processOnServer |
Specifies whether or not to process the event on the server.
|
The NumberChanged event occurs whenever the editor’s value is changed in code, by an end user typing in a new value, or by clicking any spin button.
Note
When an end user types in the editor’s text box, the editor value is not changed (and the NumberChanged event is not raised) until the value is confirmed by pressing the ENTER key, or by moving focus out of the editor.
Example
The example below demonstrates how to calculate a summary in the CategoryID column based on the value in the ASPxSpinEdit residing below. Here is how the project works:1) A custom callback is sent to the server within the editor’s client side NumberChanged event handler.2) Handle the SummaryDisplayText event to calculate the required summary value and set the e.Text parameter.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ASPxCardView1_SummaryDisplayText(object sender, DevExpress.Web.ASPxCardViewSummaryDisplayTextEventArgs e)
{
if (e.Item.FieldName == "CategoryID")
e.Text = string.Format("Sum = {0}", Convert.ToDouble(e.Value) * Convert.ToDouble(ASPxSpinEdit1.Value));
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.4.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>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxCardView ID="ASPxCardView1" KeyFieldName="CategoryID" OnSummaryDisplayText="ASPxCardView1_SummaryDisplayText" AutoGenerateColumns="False" ClientInstanceName="grid" DataSourceID="AccessDataSource1" runat="server">
<Settings ShowSummaryPanel="True" />
<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>
<TotalSummary>
<dx:ASPxCardViewSummaryItem FieldName="CategoryID" SummaryType="Sum" />
</TotalSummary>
</dx:ASPxCardView>
<br />
<dx:ASPxSpinEdit ID="ASPxSpinEdit1" runat="server" Number="0" Height="21">
<ClientSideEvents NumberChanged="function(s, e) {
grid.PerformCallback();
}" />
</dx:ASPxSpinEdit>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></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
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 ASPxCardView1_SummaryDisplayText(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxCardViewSummaryDisplayTextEventArgs)
If e.Item.FieldName = "CategoryID" Then
e.Text = String.Format("Sum = {0}", Convert.ToDouble(e.Value) * Convert.ToDouble(ASPxSpinEdit1.Value))
End If
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.4.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>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxCardView ID="ASPxCardView1" KeyFieldName="CategoryID" OnSummaryDisplayText="ASPxCardView1_SummaryDisplayText" AutoGenerateColumns="False" ClientInstanceName="grid" DataSourceID="AccessDataSource1" runat="server">
<Settings ShowSummaryPanel="True" />
<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>
<TotalSummary>
<dx:ASPxCardViewSummaryItem FieldName="CategoryID" SummaryType="Sum" />
</TotalSummary>
</dx:ASPxCardView>
<br />
<dx:ASPxSpinEdit ID="ASPxSpinEdit1" runat="server" Number="0" Height="21">
<ClientSideEvents NumberChanged="function(s, e) {
grid.PerformCallback();
}" />
</dx:ASPxSpinEdit>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
</div>
</form>
</body>
</html>
See Also