-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDefault.aspx
84 lines (79 loc) · 3.77 KB
/
Default.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ASPxGridView - How to implement copy functionality in Batch Edit mode</title>
<script type="text/javascript">
var index;
var copyFlag;
function OnCustomButtonClick(s, e) {
if (e.buttonID == "CopyButton") {
index = e.visibleIndex;
copyFlag = true;
s.AddNewRow();
}
}
function OnStartEdit(s, e) {
if (copyFlag) {
copyFlag = false;
for (var i = 0; i < s.GetColumnCount() ; i++) {
var column = s.GetColumn(i);
if (column.visible == false || column.fieldName == undefined)
continue;
ProcessCells(rbl.GetSelectedIndex(), e, column, s);
}
}
}
function ProcessCells(selectedIndex, e, column, s) {
var isCellEditMode = selectedIndex == 0;
var cellValue = s.batchEditApi.GetCellValue(index, column.fieldName);
if(isCellEditMode) {
if(column.fieldName == e.focusedColumn.fieldName)
e.rowValues[column.index].value = cellValue;
else
s.batchEditApi.SetCellValue(e.visibleIndex, column.fieldName, cellValue);
} else {
e.rowValues[column.index].value = cellValue;
}
}
</script>
</head>
<body>
<form id="frmMain" runat="server">
<dx:ASPxCheckBox ID="BatchUpdateCheckBox" runat="server" Checked="true" Text="Handle BatchUpdate event"
AutoPostBack="true" />
<dx:ASPxRadioButtonList runat="server" ID="rbl" AutoPostBack="true" OnSelectedIndexChanged="rbl_SelectedIndexChanged" ClientInstanceName="rbl">
<Items>
<dx:ListEditItem Text="Cell" Value="Cell" Selected="true" />
<dx:ListEditItem Text="Row" Value="Row" />
</Items>
</dx:ASPxRadioButtonList>
<dx:ASPxGridView ID="Grid" runat="server" ClientInstanceName="grid" KeyFieldName="ID" OnBatchUpdate="Grid_BatchUpdate"
OnRowInserting="Grid_RowInserting" OnRowUpdating="Grid_RowUpdating" OnRowDeleting="Grid_RowDeleting">
<SettingsEditing>
</SettingsEditing>
<Columns>
<dx:GridViewCommandColumn ShowNewButtonInHeader="true" ShowDeleteButton="true">
<CustomButtons>
<dx:GridViewCommandColumnCustomButton ID="CopyButton" Text="Copy"></dx:GridViewCommandColumnCustomButton>
</CustomButtons>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="C1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataSpinEditColumn FieldName="C2">
</dx:GridViewDataSpinEditColumn>
<dx:GridViewDataColumn FieldName="C3">
</dx:GridViewDataColumn>
<dx:GridViewDataCheckColumn FieldName="C4">
</dx:GridViewDataCheckColumn>
<dx:GridViewDataDateColumn FieldName="C5">
</dx:GridViewDataDateColumn>
</Columns>
<SettingsEditing Mode="Batch" />
<ClientSideEvents BatchEditStartEditing="OnStartEdit" CustomButtonClick="OnCustomButtonClick" />
</dx:ASPxGridView>
</form>
</body>
</html>