Author: abelevich
Date: 2007-04-26 05:57:13 -0400 (Thu, 26 Apr 2007)
New Revision: 566
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-04-26
09:56:53 UTC (rev 565)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-04-26
09:57:13 UTC (rev 566)
@@ -3,30 +3,89 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:sg="http://richfaces.ajax4jsf.org/scrollable-grid"
<head>
- <script type="text/javascript">
-
- function processCellValue(cell, value) {
- var cell = $(cell);
- if(cell) {
- if(value && value.indexOf("2")>0) {
- cell.setStyle({backgroundColor: "red"});
+ <script>
+ //<![CDATA[
+
+ function processCellValue(cell, value) {
+ var cell = $(cell);
+ if(cell) {
+ if(value && value.indexOf("2")>0) {
+ cell.setStyle({backgroundColor: "red"});
+ }
+ else {
+ cell.setStyle({backgroundColor: ""});
+ }
}
- else {
- cell.setStyle({backgroundColor: ""});
- }
}
- }
- function onSort(column, order) {
- alert("Column " + column + " sorted in " + order + "
order.");
- }
+ function onSort(column, order) {
+ alert("Column " + column + " sorted in " + order + "
order.");
+ }
+
+ var ExampleGrid = function() {
+ return {
+ init : function() {
+ var currTime = (new Date()).getTime();
+ ClientUILib.log(ClientUILogger.WARNING, "Document loaded over " +
(currTime - ClientUILib.startTime) + " miliseconds.");
+
+ var data = [];
+ for (var index = 0; index < 100; index++) {
+ data[index] = [];
+ for (var index2 = 0; index2 < 6; index2++) {
+ data[index][index2] = index2 + " : " + index;
+ }
+ data[index][6] = index%2 ? "value 1" : "value 2";
+ }
+
+ dataModel = new ClientUI.controls.grid.ArrayDataModel(data);
+
+ var templates = [
+ {pane: GridLayout_Enum.HEADER, ref: "GridHeaderTemplate"},
+ {pane: GridLayout_Enum.BODY, ref: "GridBodyTemplate"},
+ {pane: GridLayout_Enum.FOOTER, ref: "GridFooterTemplate"}
+ ];
+
+ ClientUILib.log(ClientUILogger.WARNING, "DataModel created over " + ((new
Date()).getTime() - currTime) + " miliseconds.");
+ currTime = (new Date()).getTime();
+
+ // create the Grid
+ var grid = new ClientUI.controls.grid.Grid('GridContainer',
dataModel, templates,
+ {
+ showIndexColumn: true,
+ indexColumnWidth: 40
+ }
+ );
+ ClientUILib.log(ClientUILogger.WARNING, "Grid control created over " +
((new Date()).getTime() - currTime) + " miliseconds.");
+
+ grid.updateLayout();
+ Event.observe(grid.eventOnSort, "grid on sort", onSort);
+
+ setTimeout(function() {
+ currTime = (new Date()).getTime();
+ grid.loadData();
+ ClientUILib.log(ClientUILogger.WARNING, "Grid data loaded over " + ((new
Date()).getTime() - currTime) + " miliseconds.");
+ }.bind(this), 100);
+
+ ClientUILib.log(ClientUILogger.WARNING, "Done.");
+ }
+ }
+ }();
+
+ Event.observe(window, 'load', ExampleGrid.init);
+
+
+ //]]>
+
</script>
</head>
<body>
+ <sg:scrollable-grid>
+ </sg:scrollable-grid>
</body>
</html>
\ No newline at end of file