diff --git a/src/main/webapp/scripts/project/data-table-view.js b/src/main/webapp/scripts/project/data-table-view.js index cd2c78601..10a98ff38 100644 --- a/src/main/webapp/scripts/project/data-table-view.js +++ b/src/main/webapp/scripts/project/data-table-view.js @@ -18,9 +18,16 @@ DataTableView.prototype.render = function() { '' ).appendTo(divSummary); - var pagingControls = $('
').addClass("viewPanel-pagingControls").appendTo(container); - var firstPage = $('« first').appendTo(pagingControls); - var previousPage = $('« previous').appendTo(pagingControls); + /* + * Paging controls + */ + + var pagingControls = $('
').addClass("viewPanel-pagingControls").appendTo(container); + var pagingControls0 = pagingControls[0].rows[0].cells[0]; + var pagingControls1 = pagingControls[0].rows[0].cells[1]; + + var firstPage = $('« first').appendTo(pagingControls0); + var previousPage = $('« previous').appendTo(pagingControls0); if (theProject.rowModel.start > 0) { firstPage.addClass("action").click(function(evt) { self._onClickFirstPage(this, evt); }); previousPage.addClass("action").click(function(evt) { self._onClickPreviousPage(this, evt); }); @@ -28,9 +35,9 @@ DataTableView.prototype.render = function() { firstPage.addClass("inaction"); previousPage.addClass("inaction"); } - $('').appendTo(pagingControls); - var nextPage = $('next page »').appendTo(pagingControls); - var lastPage = $('last »').appendTo(pagingControls); + $('').appendTo(pagingControls0); + var nextPage = $('next page »').appendTo(pagingControls0); + var lastPage = $('last »').appendTo(pagingControls0); if (theProject.rowModel.start + theProject.rowModel.limit < theProject.rowModel.filtered) { nextPage.addClass("action").click(function(evt) { self._onClickNextPage(this, evt); }); lastPage.addClass("action").click(function(evt) { self._onClickLastPage(this, evt); }); @@ -39,6 +46,27 @@ DataTableView.prototype.render = function() { lastPage.addClass("inaction"); } + $('page size: ').appendTo(pagingControls1); + var sizes = [ 5, 10, 15, 20, 25, 50 ]; + var renderPageSize = function(index) { + var pageSize = sizes[index]; + var a = $('').appendTo(pagingControls1) + if (pageSize == self._pageSize) { + a.text("[" + pageSize + "]").addClass("inaction"); + } else { + a.text(pageSize).addClass("action").click(function(evt) { + self._pageSize = pageSize; + self.update(true); + }); + } + }; + for (var i = 0; i < sizes.length; i++) { + renderPageSize(i); + } + + /* + * Data table + */ var table = document.createElement("table"); table.className = "data-table"; container.append(table);