Hi there,
I'm using ejGrid control on ASP.NET Web Froms.
When I do double click the cell to modify value and then without changing, normally no event fired like SQLBinding which is a sample code you provide.
But my grid fire OnServerEditRow event after editor mode exit without changing value in the cell.
Is there any option or something for that?
Thanks in advance.
Yong
Hi Farveen,
Please see the attached videos and compare sample code and my code.
Sample one does not fire event when value is not changed but my code fire event even value is not changed.
What did I miss it?
public partial class _Default : Page
{
private List<Orders> order = new List<Orders>();
protected void Page_Load(object sender, EventArgs e)
{
BindDataSource();
}
private void BindDataSource()
{
int orderId = 10643;
int empId = 0;
order.Add(new Orders(orderId + 1, "ALFKI", empId + 1, 4500000, "Alfreds Futterkiste ", "Germany"));
order.Add(new Orders(orderId + 2, "ANATR", empId + 2, 5500000, "Ana Trujillo Emparedados y helados", "Mexico"));
order.Add(new Orders(orderId + 3, "ANTON", empId + 3, 6500000, "Antonio Moreno Taquería", "Mexico"));
order.Add(new Orders(orderId + 4, "AROUT", empId + 4, 7500000, "Around the Horn", "UK"));
order.Add(new Orders(orderId + 5, "BERGS", empId + 5, 8500000, "Berglunds snabbköp", "Sweden"));
order.Add(new Orders(orderId + 6, "BLONP", empId + 6, 9500000, "Blondel père et fils", "France"));
this.OrdersGrid.DataSource = order;
this.OrdersGrid.DataBind();
}
[Serializable]
public class Orders
{
public Orders()
{
}
public Orders(int orderId, string customerId, int empId, double freight, string shipName, string shipCountry)
{
this.OrderID = orderId;
this.CustomerID = customerId;
this.EmployeeID = empId;
this.Freight = freight;
this.ShipName = shipName;
this.ShipCountry = shipCountry;
}
public int OrderID { get; set; }
public string CustomerID { get; set; }
public int EmployeeID { get; set; }
public double Freight { get; set; }
public string ShipName { get; set; }
public string ShipCountry { get; set; }
}
protected void EditEvents_ServerEditRow(object sender, GridEventArgs e)
{
EditAction(e.EventType, e.Arguments["data"]);
}
protected void EditEvents_ServerAddRow(object sender, GridEventArgs e)
{
EditAction(e.EventType, e.Arguments["data"]);
}
protected void EditEvents_ServerDeleteRow(object sender, GridEventArgs e)
{
EditAction(e.EventType, e.Arguments["data"]);
}
protected void EditAction(string eventType, object record)
{
if (eventType == "endEdit")
{
}
else if (eventType == "endAdd")
{
}
else if (eventType == "endDelete")
{
}
}
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="test._Default" %>
<html>
<head runat="server">
<meta charset="utf-8" />
<title></title>
<link rel='nofollow' href="Content/ej/web/default-theme/ej.web.all.min.css" rel="stylesheet" />
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/jquery.easing.1.3.min.js"></script>
<script src="Scripts/jquery.globalize.min.js"></script>
<script src="Scripts/jsrender.min.js"></script>
<script src="Scripts/ej.web.all.min.js"></script>
<script src="Scripts/ej.webform.min.js"></script>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True"
AllowSorting="True" OnServerEditRow="EditEvents_ServerEditRow"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" ActionBegin="begin"
RecordDoubleClick="doubleClick" />
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90" />
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="100" />
<ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="110" />
<ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="90" Format="{0:N2}" />
<ej:Column Field="ShipCountry" HeaderText="Ship Country" Width="100" />
</Columns>
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
</ej:Grid>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Hi Farveen,
You're right. I was using a old version and all good now after upgrading a latest version.
Thank you for your help.
Regards,
Yong