-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWebGridClientObject.cs
More file actions
61 lines (46 loc) · 1.62 KB
/
WebGridClientObject.cs
File metadata and controls
61 lines (46 loc) · 1.62 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
/*
Copyright © Olav Christian Botterli.
Dual licensed under the MIT or GPL Version 2 licenses.
Date: 30.08.2011, Norway.
http://www.webgrid.com
*/
/*
Copyright © Olav Christian Botterli.
Dual licensed under the MIT or GPL Version 2 licenses.
Date: 30.08.2011, Norway.
http://www.webgrid.com
*/
namespace WebGrid
{
/// <summary>
/// WebGrid Client object
/// </summary>
public static class WebGridClientObject
{
#region Fields
const string gridobject = @"
function {0}() {{
this.title = '{2}';
this.rows = {3};
this.editIndex = '{4}'
}}
{0}.prototype.refresh = function() {{
try{{$.fn.colorbox.close();}}catch (err){{}}
{1};
}};
{0} = new {0}();
";
#endregion Fields
#region Methods
internal static string GetGridObject(Grid grid)
{
string refresh = grid.EnableCallBack
? string.Format(
@"setActiveGrid('{1}');Anthem_InvokeControlMethod(""{0}"", ""CallBackMethod"", ""refresh"", null, null);",
grid.ClientID,grid.ID)
: grid.Page.ClientScript.GetPostBackEventReference(grid, "refresh");
return string.Format(gridobject, grid.ClientObjectId ?? grid.ID, refresh, Util.Json.Utilities.JavaScriptUtils.ToEscapedJavaScriptString(grid.Title, '\'', false), grid.RecordCount, Util.Json.Utilities.JavaScriptUtils.ToEscapedJavaScriptString(grid.EditIndex, '\'', false));
}
#endregion Methods
}
}