-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIndex.cshtml
57 lines (54 loc) · 2.09 KB
/
Index.cshtml
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
<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], "IsReserved", s.GetChecked())
}
}
function OnCellCheckedChanged(s, e) {
Grid.batchEditApi.SetCellValue(visibleIndex, "IsReserved", s.GetValue());
CheckSelectedCellsOnPage("usualCheck");
}
function OnBatchEditRowDeleting(s, e) {
DeletedValue = Grid.batchEditApi.GetCellValue(e.visibleIndex, "IsReserved");
CheckSelectedCellsOnPage("deleteCheck");
}
function OnBatchEditRowInserting(s, e) {
CheckSelectedCellsOnPage("insertCheck");
}
function OnBatchEditStartEditing(s, e) {
visibleIndex = e.visibleIndex;
}
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], "IsReserved"))
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>
@using (Html.BeginForm())
{
@Html.Action("GridViewPartialView")
}