Permalink
Browse files

progress on head.js

  • Loading branch information...
1 parent 141d218 commit 5bb3349b51a5bbc44bea6c6f732e583e262e7923 @wmchristie committed May 22, 2012
Showing with 34 additions and 14 deletions.
  1. +6 −7 assets/js/grid.js
  2. +8 −4 assets/js/head.js
  3. +20 −3 index.html
View
@@ -10,7 +10,7 @@
blank : _.template('<td class="col<%= item.c %>"><div class="data"><span></span></div></td>'),
head : _.template(
- '<th class="col<%= item.ordinal %> <%= item.align %><%= item.sizable %><%= item.sortable %><%= item.sort %>">' +
+ '<th class="col<%= item.ordinal %><%= item.sizable %><%= item.sortable %><%= item.sort %>">' +
' <div class="cell">' +
' <div class="side west"></div>' +
' <div class="data">' +
@@ -29,7 +29,7 @@
};
- var show = function (dom, rows, colStart) {
+ var show = function (dom, head, rows, colStart) {
var start = new Date();
@@ -74,17 +74,16 @@
var markupTime,
insertTime,
- factory = new app.RowFactory(),
- rows = factory.create(app.data.records),
- head = app.createColumnHead(app.data.primary
+ rows = new app.RowFactory().create(app.data.records),
+ head = new app.HeadFactory().create(app.data.primaryView),
dom = app.gridDom(document.getElementById('grid_container')),
colStart = 0;
- show(dom, rows, colStart++);
+ show(dom, head, rows, colStart++);
$('#by_cell').on('click', function () {
- show(dom, rows, colStart++);
+ show(dom, head, rows, colStart++);
});
});
View
@@ -6,6 +6,7 @@
lookup = [],
min = Math.min,
+ template = app.gridTemplates.head,
titleRegex = /<[a-z\/][^>]*>/g;
@@ -28,7 +29,7 @@
for (; i < limit; i++) {
- result += template(column);
+ result += template(lookup[i]);
}
@@ -55,15 +56,18 @@
app.HeadFactory.prototype = {
- create : function (columns) {
+ create : function (view) {
- return app.createColumnHead(_.map(columns, function (column) {
+ return app.createColumnHead(_.map(view.columns, function (column) {
return {
+ align : column.align,
name : column.name,
ordinal : column.ordinal,
sortable : column.sortable ? ' sortable' : '',
-
+ sizable : column.sizable ? ' sizable' : '',
+ sort : '',
+ sortIndicator : ''
};
}));
View
@@ -8,24 +8,41 @@
table {
border-collapse: collapse;
+ position: relative;
width: 100%;
}
+
+ thead {
+ position: absolute;
+ top: 0;
+ }
+
+ tbody {
+ position: relative;
+ top: 60px;
+ }
+
.container {
margin: 20px;
border: 1px solid;
height: 500px;
width : 1000px;
overflow: auto;
}
- td {
- padding: 0 5px;
+
+ th {
+ background: #00f;
+ color: #fff;
}
+ th .data,
td .data {
+ height: 24px;
+ padding: 0 5px;
overflow: hidden;
+ text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
- height: 24px;
}
tr.odd {

0 comments on commit 5bb3349

Please sign in to comment.