-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSystem.Web.UI.WebControls.debug.js
More file actions
179 lines (164 loc) · 5.94 KB
/
System.Web.UI.WebControls.debug.js
File metadata and controls
179 lines (164 loc) · 5.94 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//=============================================================================
// Jocys.com JavaScript.NET Classes (In C# Object Oriented Style)
// Created by Evaldas Jocys <evaldas@jocys.com>
//=============================================================================
/// <reference path="System.debug.js" />
//=============================================================================
// Namespaces
//-----------------------------------------------------------------------------
// <PropertyGroup>
// <RootNamespace>System.Web.UI.WebControls</RootNamespace>
// <PropertyGroup>
//-----------------------------------------------------------------------------
System.Type.RegisterNamespace("System.Web.UI.WebControls");
//=============================================================================
//=============================================================================
// CLASS:
//-----------------------------------------------------------------------------
System.Web.UI.WebControls.InitDialog = function (sender, e) {
System.Web.UI.WebControls.DialogBox.OnClick(sender, e);
var prefixEnd = sender.id.lastIndexOf("_") + 1 + e.Prefix.length;
var prefix = sender.id.substring(0, prefixEnd);
var parentEnd = sender.id.lastIndexOf("_");
var parentId = sender.id.substring(0, parentEnd + 1);
var tableId = prefix + "Table";
var dialogPanelId = prefix + "DialogPanel";
var holderPanelId = prefix + "HolderPanel";
var searchButtonId = prefix + "SearchButton";
var clearButtonId = prefix + "ClearButton";
if (!$("#" + holderPanelId).length) {
alert("#" + e.Prefix + "HolderPanel not found");
}
if (!$("#" + dialogPanelId).length) {
alert("#" + e.Prefix + "DialogPanel not found");
}
if (!$("#" + tableId).length) {
alert("#" + e.Prefix + "Table not found");
}
$("#" + holderPanelId).css("display", "none");
System.Web.UI.WebControls.ListView.FixTable(tableId);
function callCommand(sender, eFrom, eTo, commandName) {
eTo.CommandName = commandName;
eTo.FindControl = function (id) {
var end = prefix.lastIndexOf("_");
var parentId = prefix.substring(0, end + 1);
return $("#" + parentId + id);
};
// Pass properties from parrent event arguments.
for (var name in eFrom) {
eTo[name] = eFrom[name];
}
// Call command.
eFrom.DataTableItemCommand(sender, eTo);
}
callCommand(this, e, {}, "DialogOpen");
// Update static function to make sure that it is using current 'e'.
e.DialogButton = $("#" + sender.id);
System.Web.UI.WebControls.CurrentE = e;
var table;
if ($.fn.dataTable.isDataTable("#" + tableId)) {
//table = $("#" + tableId).DataTable();
table = $("#" + tableId).DataTable();
for (var i = 0; i < e.Columns.length; i++) {
table.columns(i).visible(e.Columns[i].visible);
}
table.page(0).draw(false);
table.ajax.reload(null, false);
} else {
// Create DataTable object.
table = $("#" + tableId).DataTable({
processing: true,
pageLength: 100,
scrollY: "400px",
scrollCollapse: true,
//paging: false
sort: e.DataTableSort ? true : false,
// Move dialog to the center on every draw event of the table.
drawCallback: function (settings) {
var e2 = { CancelDataBound: false };
callCommand(this, e, e2, "DataBound");
if (e2.CancelDataBound === true)
{
// Enable open dialog button.
e.DialogButton.attr("disabled", null);
// Close dialog.
$("#" + dialogPanelId).dialog("close");
} else {
$("#" + holderPanelId).css("display", "block");
$("#" + dialogPanelId).dialog({
position: { my: "center", at: "center", of: window }
});
}
},
// Hide page size dropdown box.
lengthChange: false,
// Hide search box.
filter: false,
ajax: {
url: e.Url,
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function (jqXHR, settings) {
var e = System.Web.UI.WebControls.CurrentE;
callCommand(this, e, { Item: data }, "BeforeSend");
if (typeof e.Search !== "undefined") {
for (var i = 0; i < e.Search.length; i++) {
var name = e.Search[i].name;
var data = e.Search[i].data;
var value = $("#" + parentId + name).val();
settings.url += "&" + data + "=" + encodeURIComponent(value);
}
}
return true;
},
dataFilter: function (data, type) {
var json = $.parseJSON(data);
if (json && json.hasOwnProperty("d")) json = json.d;
return json;
}
},
columns: e.Columns,
serverSide: true,
select: true
});
// Reload data when Search buton is clicked.
$("#" + searchButtonId).on('click', function () {
table.ajax.reload(null, false);
});
// Clear search and reload data when [Clear] button is pressed.
$("#" + clearButtonId).on('click', function () {
for (var i = 0; i < e.Search.length; i++) {
var name = e.Search[i].name;
$("#" + parentId + name).val("");
}
table.ajax.reload(null, false);
});
if (typeof e.Search !== "undefined") {
// Reload table when [Enter] is pressed inside search box.
for (var j = 0; j < e.Search.length; j++) {
var name = e.Search[j].name;
$("#" + parentId + name).keypress(function (e) {
if (e.which === 13) {
table.ajax.reload(null, false);
}
});
}
}
$("#" + tableId + " tbody").on('click', 'tr', function () {
var e = System.Web.UI.WebControls.CurrentE;
var data = table.row(this).data();
if (typeof data !== "undefined") {
// Enable open dialog button.
e.DialogButton.attr("disabled", null);
// Close DialogBox.
callCommand(this, e, { Item: data }, "Select");
// Close dialog.
$("#" + dialogPanelId).dialog("close");
}
});
}
};
//==============================================================================
// END
//------------------------------------------------------------------------------