-
Notifications
You must be signed in to change notification settings - Fork 1
/
Default.aspx
116 lines (111 loc) · 5.98 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v17.1, Version=17.1.17.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">
var visibleIndex;
var DeletedValue;
function OnInitHeader(s, e) {
setTimeout(function() { CheckSelectedCellsOnPage("usualCheck"); }, 0);
}
function OnHeaderCheckBoxCheckedChanged(s, e) {
var visibleIndices = Grid.batchEditApi.GetRowVisibleIndices();
var totalRowsCountOnPage = visibleIndices.length;
for (var i = 0; i < totalRowsCountOnPage ; i++) {
Grid.batchEditApi.SetCellValue(visibleIndices[i], "Discontinued", s.GetChecked())
}
}
function OnCellCheckedChanged(s, e) {
Grid.batchEditApi.EndEdit();
}
function OnBatchEditEndEditing(s, e) {
setTimeout(function() {
CheckSelectedCellsOnPage("usualCheck");
}, 0);
}
function OnBatchEditRowDeleting(s, e) {
DeletedValue = Grid.batchEditApi.GetCellValue(e.visibleIndex, "Discontinued");
CheckSelectedCellsOnPage("deleteCheck");
}
function OnBatchEditRowInserting(s, e) {
CheckSelectedCellsOnPage("insertCheck");
}
function CheckSelectedCellsOnPage(checkType) {
var currentlySelectedRowsCount = 0;
var visibleIndices = Grid.batchEditApi.GetRowVisibleIndices();
var totalRowsCountOnPage = visibleIndices.length;
for (var i = 0; i < totalRowsCountOnPage ; i++) {
if (Grid.batchEditApi.GetCellValue(visibleIndices[i], "Discontinued"))
currentlySelectedRowsCount++;
}
if (checkType == "insertCheck")
totalRowsCountOnPage++;
else if (checkType == "deleteCheck") {
totalRowsCountOnPage--;
if (DeletedValue)
currentlySelectedRowsCount--;
}
if (currentlySelectedRowsCount <= 0)
HeaderCheckBox.SetCheckState("Unchecked");
else if (currentlySelectedRowsCount >= totalRowsCountOnPage)
HeaderCheckBox.SetCheckState("Checked");
else
HeaderCheckBox.SetCheckState("Indeterminate");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="AccessDataSource1" AutoGenerateColumns="False" ClientInstanceName="Grid" KeyFieldName="ProductID"
OnCustomErrorText="ASPxGridView1_CustomErrorText" OnRowUpdating="ASPxGridView1_RowUpdating">
<SettingsEditing Mode="Batch">
</SettingsEditing>
<ClientSideEvents BatchEditRowDeleting="OnBatchEditRowDeleting" BatchEditEndEditing="OnBatchEditEndEditing"
BatchEditRowInserting="OnBatchEditRowInserting" />
<SettingsPager PageSize="10"></SettingsPager>
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0" ShowNewButtonInHeader="true" ShowDeleteButton="true">
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="SupplierID" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="4">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="QuantityPerUnit" VisibleIndex="5">
</dx:GridViewDataTextColumn>
<dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="6">
<PropertiesCheckEdit>
<ClientSideEvents CheckedChanged="OnCellCheckedChanged" />
</PropertiesCheckEdit>
<HeaderTemplate>
<dx:ASPxCheckBox ID="HeaderCheckBox" ClientIDMode="Static" runat="server" ClientInstanceName="HeaderCheckBox" AllowGrayed="true" AllowGrayedByClick="false">
<ClientSideEvents CheckedChanged="OnHeaderCheckBoxCheckedChanged" Init="OnInitHeader" />
</dx:ASPxCheckBox>
</HeaderTemplate>
<Settings AllowSort="False" />
</dx:GridViewDataCheckColumn>
</Columns>
</dx:ASPxGridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [Discontinued] FROM [Products]"
UpdateCommand="UPDATE [Products] SET [ProductName] = ?, [SupplierID] = ?, [CategoryID] = ?, [QuantityPerUnit] = ?, [Discontinued] = ? WHERE [ProductID] = ?">
<UpdateParameters>
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="SupplierID" Type="Int32" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="QuantityPerUnit" Type="String" />
<asp:Parameter Name="Discontinued" Type="Boolean" />
<asp:Parameter Name="ProductID" Type="Int32" />
</UpdateParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>