-
Notifications
You must be signed in to change notification settings - Fork 0
/
getRows.html
130 lines (128 loc) · 7.11 KB
/
getRows.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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="jqwidgets/jqxgrid.js"></script>
<script type="text/javascript" src="jqwidgets/jqxgrid.selection.js"></script>
<script type="text/javascript" src="jqwidgets/jqxgrid.columnsresize.js"></script>
<!--<script type="text/javascript" src="scripts/gettheme.js"></script>-->
<script type="text/javascript">
$(document).ready(function() {
//var theme = getDemoTheme();
$("#jqxButton").jqxButton({width: '150'});
// prepare the data
var data = new Array();
var firstNames =
[
"Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
];
var lastNames =
[
"Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
];
var productNames =
[
"Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist"
];
var priceValues =
[
"2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0"
];
for (var i = 0; i < 200; i++) {
var row = {};
var productindex = Math.floor(Math.random() * productNames.length);
var price = parseFloat(priceValues[productindex]);
var quantity = 1 + Math.round(Math.random() * 10);
row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)];
row["productname"] = productNames[productindex];
row["price"] = price;
row["quantity"] = quantity;
row["total"] = price * quantity;
data[i] = row;
}
var source =
{
localdata: data,
datatype: "array",
datafields:
[
{name: 'firstname', type: 'string'},
{name: 'lastname', type: 'string'},
{name: 'productname', type: 'string'},
{name: 'quantity', type: 'number'},
{name: 'price', type: 'number'},
{name: 'total', type: 'number'}
]
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid(
{
width: 670,
source: dataAdapter,
columnsresize: true,
columns: [
{text: 'Name', dataField: 'firstname', width: 100},
{text: 'Last Name', dataField: 'lastname', width: 100},
{text: 'Product', editable: false, dataField: 'productname', width: 180},
{text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right'},
{text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2'},
{text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2'}
]
});
$("#jqxgrid2").jqxGrid(
{
width: 670,
columnsresize: true,
columns: [
{text: 'Name', dataField: 'firstname', width: 100},
{text: 'Last Name', dataField: 'lastname', width: 100},
{text: 'Product', editable: false, dataField: 'productname', width: 180},
{text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right'},
{text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2'},
{text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2'}
]
});
data2 = [];
$("#jqxgrid").bind('rowselect', function(event) {
rowindex = event.args.rowindex;
data2.push(data[rowindex]);
var source =
{
localdata: data2,
datatype: "array",
datafields:
[
{name: 'firstname', type: 'string'},
{name: 'lastname', type: 'string'},
{name: 'productname', type: 'string'},
{name: 'quantity', type: 'number'},
{name: 'price', type: 'number'},
{name: 'total', type: 'number'}
]
};
var dataAdapter2 = new $.jqx.dataAdapter(source);
$("#jqxgrid2").jqxGrid({source: dataAdapter2});
});
});
</script>
</head>
<body class='default'>
<div>Select rows to copy to</div>
<div id='jqxWidget'>
<div id="jqxgrid">
</div>
<div id="jqxgrid2" style="margin-top: 20px;">
</div>
<div>
<input type="button" value="Save" id='jqxButton' />
</div>
</div>
</body>
</html>