-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
executable file
·220 lines (176 loc) · 17.5 KB
/
example.html
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<html>
<head>
<script src="./jquery.cooltable.js"></script>
<script src="./jquery-1.6.2.min.js"></script>
<style>
table.crmgrid { border-collapse: collapse; border: 1px solid #6287a5; width: 540px;}
table.crmgrid td { padding: 2px; border: 1px solid #6287a5; font-size: 9px;}
table.crmgrid th { padding: 0px; border: 1px solid #6287a5; font-size: 9px;}
table.crmgrid th { background: #E5E5E5; font-size: 10px; -webkit-touch-callout: none; -webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;outline-style:none;}
tr.crmgridPaginator td{background: #ffffff; text-align: center; font-size: 10px; -webkit-touch-callout: none; -webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;outline-style:none;}
tr.crmgridrow01 { background:#fcfcfc; }
tr.crmgridrow02 { background:#d8e6f0; }
</style>
</head>
<body>
<div id="rcGrid" ></div>
<div id="rcPaginator"></div>
<br>
<input type="button" value="add single row" onclick="addRow()"/>
<input type="button" value="add multiple rows" onclick="addRows()"/>
<input type="button" value="remove last row" onclick="removeRow()"/>
<script>
var MyUtil ={
sortListByField:function (ranarray, sortfield) {
var x, y, holder;
// The Bubble Sort method.
for (x = 0; x < ranarray.length; x++) {
var swapOccured = false;
for (y = 0; y < (ranarray.length - 1); y++) {
if (ranarray[y][sortfield] > ranarray[y + 1][sortfield]) {
holder = ranarray[y + 1];
ranarray[y + 1] = ranarray[y];
ranarray[y] = holder;
swapOccured = true;
}
}
if (!swapOccured) break;
}
},
formatNumber:function(nStr){
if( nStr===undefined || nStr==null )return '';
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? ',' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '.' + '$2');
}
return x1 + x2.substring(0,3); //virgulden sonra sadece 2 karakter goster.
},
removeNull:function(v){
return (v === undefined || v == null) ? "" : v;
},
log: function(){
if(typeof(top.console)!=='undefined'){
try{top.console.log(JSON.stringify(arguments)); }
catch(e){}
}
}
}
var tablo ;
var rowId;
$(document).ready(function () {
var gridName = "bchGrid";
var imageFunction = function (rowdata,celldata){
return $('<span>').
append($('<img></img>')
.attr('src','/Advisor/xAdvisorWeb/images/kredi_kullanimi.png')
.attr('height','16')
.attr('title','Credit Usage')
.css({'cursor':'pointer','padding-left':'1px','padding-right':'1px'})
.click(function(){alert('do what you want here!');}))
.append($('<img></img>')
.attr('src','/Advisor/xAdvisorWeb/images/borc_odeme.png')
.attr('height','16')
.attr('title','Loan Payment')
.css({'cursor':'pointer','padding-left':'1px','padding-right':'1px'})
.click(function(){alert('do what you want here!');}))
.append($('<img></img>')
.attr('src','/Advisor/xAdvisorWeb/images/icon-kapama.png')
.attr('height','16')
.attr('title','Close Credit')
.css({'cursor':'pointer','padding-left':'1px','padding-right':'1px'})
.click(function(){alert('do what you want here!');}));
}
var dateSort1 = function (a,b) {
var pad ='00';
var arr = a.values['openingDate'].split("/");
var aNum = Number(arr[2]+(pad+arr[1]).slice(-pad.length)+(pad+arr[0]).slice(-pad.length));
arr = b.values['openingDate'].split("/");
var bNum = Number(arr[2]+(pad+arr[1]).slice(-pad.length)+(pad+arr[0]).slice(-pad.length));
if(aNum>bNum)
return -1;
else if(aNum<bNum)
return 1;
else
return 0;
};
var dateSort2 = function (a,b) {
var pad ='00';
var arr = a.values['maturityStartDate'].split("/");
var aNum = Number(arr[2]+(pad+arr[1]).slice(-pad.length)+(pad+arr[0]).slice(-pad.length));
arr = b.values['maturityStartDate'].split("/");
var bNum = Number(arr[2]+(pad+arr[1]).slice(-pad.length)+(pad+arr[0]).slice(-pad.length));
if(aNum>bNum)
return -1;
else if(aNum<bNum)
return 1;
else
return 0;
};
var metadata = [];
metadata.push({ name: "status", label: "Status", datatype: "string",headerStyle:{"min-width":"70px"},renderFunction:function(rowdata,celldata){ return $('<span>').text('.'+celldata.substring(celldata.indexOf(' '),celldata.length)).attr('title',celldata);},filterable:true});
metadata.push({ name: "creditNo", label:"Credit Number", datatype: "string",headerStyle:{"width":"50px"},filterable:true});
metadata.push({ name: "creditType", label:"Credit Type", datatype: "string",headerStyle:{"width":"50px"}});
metadata.push({ name: "creditCode", label: "Credit Code", datatype: "string",headerStyle:{"width":"30px"}});
metadata.push({ name: "currencyCode", label: "Currency Code", datatype: "string",headerStyle:{"width":"30px"}});
metadata.push({ name: "limit", label: "Limit", datatype:"string",headerStyle:{"min-width":"50px"},dataStyle:{"text-align":"right"},renderFunction:function(rowdata,celldata){ return MyUtil.formatNumber(celldata);}});
metadata.push({ name: "openingDate", label: "Opening Date", datatype: "string",headerStyle:{"width":"40px"},customSortFunction:dateSort1});
metadata.push({ name: "maturityStartDate", label: "Maturity Start Date", datatype: "string",headerStyle:{"width":"40px"},customSortFunction:dateSort2});
metadata.push({ name: "totalInterestRate", label: "Interest Rate", datatype: "string",headerStyle:{"width":"30px"},dataStyle:{"text-align":"right"}});
metadata.push({ name: "balance", label: "Balance", datatype: "string",headerStyle:{"min-width":"49px"},dataStyle:{"text-align":"right"},renderFunction:function(rowdata,celldata){ return MyUtil.formatNumber(celldata);}});
metadata.push({ name: "link", label: "", datatype: "img",headerStyle:{"width":"10px"},sortable:"false"/*,renderFunction:imageFunction*/});
function rowDblClicked(event) {
MyUtil.log(event.data);
}
function rowClicked(event) {
alert(event.data.values.creditNo);
}
var rowSettings = {evenRowStyle:{"background":"#d8e6f0","height":"18px"},oddRowStyle:{"background":"#fcfcfc","height":"18px"},hoverStyle:{"background-color":"#99CCFF"},rowFunctions:[{eventType:"dblclick",functionToCall:rowDblClicked},{eventType:"click",functionToCall:rowClicked}]};
var data = [{"status":"Opened But Not Used","creditNo":"55030","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":20000000,"openingDate":"27/02/2014","maturityStartDate":"28/02/2014","totalInterestRate":0,"balance":15000000,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55055","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"14/03/2014","maturityStartDate":"14/03/2014","totalInterestRate":0,"balance":1000,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55063","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":3000,"openingDate":"14/03/2014","maturityStartDate":"14/03/2014","totalInterestRate":0,"balance":857.15,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55097","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"26/03/2014","maturityStartDate":"24/03/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55111","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"26/03/2014","maturityStartDate":"26/03/2014","totalInterestRate":0,"balance":150,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55137","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"05/05/2014","maturityStartDate":"05/05/2014","totalInterestRate":11.3,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55145","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"05/05/2014","maturityStartDate":"05/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55152","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"06/05/2014","maturityStartDate":"06/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55160","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"06/05/2014","maturityStartDate":"06/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55178","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"07/05/2014","maturityStartDate":"07/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55186","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":2000,"openingDate":"08/05/2014","maturityStartDate":"27/02/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55194","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"08/05/2014","maturityStartDate":"08/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56289","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":2000,"openingDate":"09/05/2014","maturityStartDate":"27/02/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56297","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"09/05/2014","maturityStartDate":"09/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56303","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"15/05/2014","maturityStartDate":"15/05/2014","totalInterestRate":11.54,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56311","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"16/05/2014","maturityStartDate":"16/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56329","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"20/05/2014","maturityStartDate":"20/05/2014","totalInterestRate":20,"balance":100,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56337","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"20/05/2014","maturityStartDate":"20/05/2014","totalInterestRate":20,"balance":250,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56345","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"21/05/2014","maturityStartDate":"21/05/2014","totalInterestRate":11.52,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56360","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"05/06/2014","maturityStartDate":"05/06/2014","totalInterestRate":20,"balance":10,"branchCode":"DNZL"}];
var rowData = [];
for(var i = 0;i< data.length;i++) {
var inp = data[i];
var temp = {id: i,values: {"status":inp.status,"creditNo":inp.creditNo,
"creditType":inp.creditType, "creditCode":inp.creditCode,
"currencyCode":inp.currencyCode,"limit":inp.limit,
"openingDate":inp.openingDate,"maturityStartDate":inp.maturityStartDate,
"totalInterestRate":inp.totalInterestRate,"balance":inp.balance,"link":"","branchCode":inp.branchCode}};
rowData.push(temp);
}
var pageSize = 6;
tablo = new CoolTable('rcGrid',metadata,rowData,'crmgrid',pageSize,rowSettings);
tablo.drawTable();
rowId = data.length;
});
function addRow(){
var temp = {id: rowId,values: {"status":"Opened But Not Used","creditNo":"56360","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"05/06/2014","maturityStartDate":"05/06/2014","totalInterestRate":20,"balance":10,"branchCode":"DNZL"}};
tablo.appendRow(temp);
rowId++;
}
function addRows(){
var data = [{"status":"Opened But Not Used","creditNo":"55030","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":20000000,"openingDate":"27/02/2014","maturityStartDate":"28/02/2014","totalInterestRate":0,"balance":15000000,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55055","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"14/03/2014","maturityStartDate":"14/03/2014","totalInterestRate":0,"balance":1000,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55063","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":3000,"openingDate":"14/03/2014","maturityStartDate":"14/03/2014","totalInterestRate":0,"balance":857.15,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55097","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"26/03/2014","maturityStartDate":"24/03/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55111","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"26/03/2014","maturityStartDate":"26/03/2014","totalInterestRate":0,"balance":150,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55137","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"05/05/2014","maturityStartDate":"05/05/2014","totalInterestRate":11.3,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55145","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"05/05/2014","maturityStartDate":"05/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55152","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"06/05/2014","maturityStartDate":"06/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55160","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"06/05/2014","maturityStartDate":"06/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55178","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"07/05/2014","maturityStartDate":"07/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55186","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":2000,"openingDate":"08/05/2014","maturityStartDate":"27/02/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"55194","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"08/05/2014","maturityStartDate":"08/05/2014","totalInterestRate":11.4,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56289","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":2000,"openingDate":"09/05/2014","maturityStartDate":"27/02/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56297","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"09/05/2014","maturityStartDate":"09/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56303","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"15/05/2014","maturityStartDate":"15/05/2014","totalInterestRate":11.54,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56311","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"16/05/2014","maturityStartDate":"16/05/2014","totalInterestRate":0,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56329","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"20/05/2014","maturityStartDate":"20/05/2014","totalInterestRate":20,"balance":100,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56337","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":1000,"openingDate":"20/05/2014","maturityStartDate":"20/05/2014","totalInterestRate":20,"balance":250,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56345","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"21/05/2014","maturityStartDate":"21/05/2014","totalInterestRate":11.52,"balance":0,"branchCode":"DNZL"},{"status":"Opened But Not Used","creditNo":"56360","creditType":"RC","creditCode":"AAAAAA","currencyCode":"TRY","limit":100,"openingDate":"05/06/2014","maturityStartDate":"05/06/2014","totalInterestRate":20,"balance":10,"branchCode":"DNZL"}];
var rowData = [];
for(var i = 0;i< data.length;i++) {
var inp = data[i];
var temp = {id: rowId,values: {"status":inp.status,"creditNo":inp.creditNo,
"creditType":inp.creditType, "creditCode":inp.creditCode,
"currencyCode":inp.currencyCode,"limit":inp.limit,
"openingDate":inp.openingDate,"maturityStartDate":inp.maturityStartDate,
"totalInterestRate":inp.totalInterestRate,"balance":inp.balance,"link":"","branchCode":inp.branchCode}};
rowData.push(temp);
rowId++;
}
tablo.appendRow(rowData);
}
function removeRow(){
if(rowId >= 0) {
rowId--;
tablo.removeRow(rowId);
}
}
</script>
</body>
</html>