Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions test/src/org/labkey/test/pages/DataGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public Void apply(Void aVoid)

public void assertRowCount(int count)
{
if (count > 1000)
if (count > 25)
{
_test.waitForElements(Locators.dataRow, 1000);
_test.waitForElements(Locators.dataRow, 25);
Assert.assertEquals("Wrong number of rows in export", count, getExportRowCount());
}
else
Expand All @@ -156,11 +156,26 @@ public void assertRowCount(int count)
}
}

public void assertPageTotal(int pages)
{
_test.waitForElement(Locators.totalPages.containing(Integer.toString(pages)));
}

public void assertCurrentPage(int page)
{
_test.waitForFormElementToEqual(Locators.currentPage, Integer.toString(page));
}

public void assertSortPresent(String columnName)
{
_test.waitForElement(Locator.tagWithClassContaining("div", "x-column-header-sort-").withText(columnName));
}

public void assertCellContent(String content)
{
_test.waitForElement(Locators.cellLocator(content));
}

@LogMethod
public void sort(@LoggedParam final String columnName)
{
Expand Down Expand Up @@ -191,6 +206,12 @@ public int getExportRowCount()
}
}

public void setCurrentPage(int page)
{
_test.setFormElement(Locators.currentPage, Integer.toString(page));
_test.pressEnter(Locators.currentPage);
}

public File exportGrid()
{
return _test.clickAndWaitForDownload(Locator.css("a.gridexportbtn"));
Expand All @@ -211,6 +232,8 @@ public static class Locators
public static Locator.CssLocator grid = Locator.css("div.connector-grid");
public static Locator.CssLocator dataRow = grid.append(Locator.css("tr.x-grid-data-row"));
public static Locator.CssLocator sysmsg = Locator.css("div.sysmsg");
public static Locator.CssLocator totalPages = Locator.css("label.x-box-item");
public static Locator.CssLocator currentPage = Locator.css("input.x-form-field");

public static Locator.XPathLocator columnHeaderLocator(String columnHeaderName)
{
Expand Down
43 changes: 42 additions & 1 deletion test/src/org/labkey/test/tests/CDSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,31 @@ public void verifyGrid()

CDSHelper.NavigationLink.GRID.makeNavigationSelection(this);

waitForText("Export to see all data."); // grid warning
waitForText("View data grid"); // grid warning

gridColumnSelector.addGridColumn("NAb", "Point IC50", true, true);
gridColumnSelector.addGridColumn("NAb", "Lab", false, true);
grid.ensureColumnsPresent("Point IC50", "Lab");
grid.assertRowCount(2969);
grid.assertPageTotal(119);

//
// Check paging buttons with known dataset. Verify with first and last subject id on page.
//
log("Verify grid paging");
grid.sort("Subject Id");
click(CDSHelper.Locators.cdsButtonLocator(">>"));
grid.assertCurrentPage(119);
grid.assertCellContent("9181");
grid.assertCellContent("9199");

click(CDSHelper.Locators.cdsButtonLocator("<"));
grid.assertCurrentPage(118);
grid.assertCellContent("9156");
grid.assertCellContent("9180");
click(CDSHelper.Locators.cdsButtonLocator("<<"));
grid.assertCellContent("193001");
grid.assertCellContent("193002");

//
// Navigate to Summary to apply a filter
Expand Down Expand Up @@ -656,36 +675,56 @@ public void verifyGrid()

grid.setFacet("Race", "White");
grid.assertRowCount(702);
grid.assertPageTotal(29);
_asserts.assertFilterStatusCounts(84,3,3);

//
// Check paging buttons and page selector with filtered dataset.
//
log("Verify grid paging with filtered dataset");
grid.sort("Subject Id");
click(CDSHelper.Locators.cdsButtonLocator(">"));
grid.assertCurrentPage(2);
grid.assertCellContent("9149");
grid.assertCellContent("9102");

grid.setCurrentPage(20);
grid.assertCellContent("193087");
grid.assertCellContent("193088");

log("Change column set and ensure still filtered");
gridColumnSelector.addGridColumn("NAb", "Point IC50", false, true);
grid.ensureColumnsPresent("Point IC50");
grid.assertRowCount(702);
grid.assertPageTotal(29);
_asserts.assertFilterStatusCounts(84, 3, 3);

log("Add a lookup column");
gridColumnSelector.addLookupColumn("NAb", "Lab", "PI");
grid.ensureColumnsPresent("Point IC50", "Lab", "PI");
grid.assertRowCount(702);
grid.assertPageTotal(29);
_asserts.assertFilterStatusCounts(84, 3, 3);

log("Filter on a looked-up column");
grid.setFacet("PI", "Mark Igra");
waitForElement(CDSHelper.Locators.filterMemberLocator("Race: = White"));
waitForElement(CDSHelper.Locators.filterMemberLocator("Lab/PI: = Mark Igra"));
grid.assertRowCount(443);
grid.assertPageTotal(18);
_asserts.assertFilterStatusCounts(15, 2, 2);

log("Filter undo on grid");
cds.clearFilter();
grid.assertRowCount(2969);
grid.assertPageTotal(119);
_asserts.assertDefaultFilterStatusCounts();

click(Locator.linkWithText("Undo"));
waitForElement(CDSHelper.Locators.filterMemberLocator("Race: = White"));
waitForElement(CDSHelper.Locators.filterMemberLocator("Lab/PI: = Mark Igra"));
grid.assertRowCount(443);
grid.assertPageTotal(18);
_asserts.assertFilterStatusCounts(15, 2, 2);

grid.setFilter("Point IC50", "Is Greater Than", "60");
Expand All @@ -694,8 +733,10 @@ public void verifyGrid()
grid.assertRowCount(13);
grid.clearFilters("Point IC50");
grid.assertRowCount(2135);
grid.assertPageTotal(86);
grid.clearFilters("PI");
grid.assertRowCount(2969);
grid.assertPageTotal(119);
assertElementPresent(Locator.css(".filterpanel").containing("All subjects")); // ensure there are no app filters remaining

grid.sort("Lab");
Expand Down
2 changes: 1 addition & 1 deletion test/src/org/labkey/test/util/CDSHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void enterApplication()
{
_test.goToProjectHome();
_test.clickAndWait(Locator.linkWithText("Application"));
_test.addUrlParameter("maxRows=1000&_showPlotData=true");
_test.addUrlParameter("_showPlotData=true");

_test.assertElementNotPresent(Locator.linkWithText("Home"));
_test.waitForElement(Locator.tagContainingText("h1", "Welcome to the HIV Vaccine"));
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/model/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Ext.define('Connector.model.Grid', {

getMaxRows : function() {

var max = 500;
var max = 25;
var params = LABKEY.ActionURL.getParameters();

if (Ext.isDefined(params['maxRows'])) {
Expand Down
159 changes: 157 additions & 2 deletions webapp/Connector/src/view/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Ext.define('Connector.view.Grid', {

headerHeight: 160,

paging: true,

constructor : function(config) {
this.callParent([config]);
this.addEvents('applyfilter', 'removefilter', 'measureselected');
Expand Down Expand Up @@ -123,6 +125,92 @@ Ext.define('Connector.view.Grid', {
});
},

_createFooter : function() {

return Ext.create ('Ext.container.Container', {
height: this.headerHeight,
ui: 'custom',
margin: '10 0 0 15',
id: 'grid-paging-footer',
layout: {
type: 'hbox',
align: 'center'
},
items: [{
// This allows for the following items to be centered
xtype: 'box',
flex: 1,
autoEl: {
tag: 'div'
}
},{
xtype: 'button',
text: '<<',
margin: '0 15 0 0',
handler: this.requestFirstPage,
scope: this
},{
xtype: 'button',
text: '<',
margin: '0 15 0 0',
handler: this.requestPreviousPage,
scope: this
},{
xtype: 'textfield',
id: 'grid-page-number',
hideLabel: true,
width: 30,
value: 1,
enableKeyEvents: true,
listeners: {
specialkey: this.requestPage
}
},{
id: 'grid-page-total',
xtype: 'label',
text: 'of ' + Math.ceil(this.getGrid().getStore().totalCount/this.getGrid().getStore().pageSize),
margin: '5 10 0 5'

},{
xtype: 'button',
text: '>',
margin: '0 15 0 0',
handler: this.requestNextPage,
scope: this
},{
xtype: 'button',
text: '>>',
margin: '0 15 0 0',
handler: this.requestLastPage,
scope: this
},{
// This allows for the following items to be centered
xtype: 'box',
flex: 1,
autoEl: {
tag: 'div'
}
}]
});
},

_updateFooter : function() {
if (this.footer) {

var totalPagesEl = this.footer.getComponent('grid-page-total');
var totalPages = Math.ceil(this.getGrid().getStore().totalCount/this.getGrid().getStore().pageSize);
if (totalPagesEl)
totalPagesEl.setText("of " + totalPages);

var currentPageEl = this.footer.getComponent('grid-page-number');
if (currentPageEl && parseInt(currentPageEl.getValue()) > totalPages) {
this.requestFirstPage()
}

this.updatePageNumber();
}
},

_showOverlay : function() {
if (!this.NO_SHOW) {

Expand Down Expand Up @@ -227,10 +315,14 @@ Ext.define('Connector.view.Grid', {

if (prevGridId != null && prevGridId != newGrid.getId()) {
this.remove(prevGridId, true);
if(this.paging && this.footer)
this.remove(this.footer, true);
this._hideOverlay();
}

this.add(newGrid);
if (this.paging)
this.footer = this.add(this._createFooter());

}, this, {single: true});
},
Expand Down Expand Up @@ -408,6 +500,7 @@ Ext.define('Connector.view.Grid', {
columns: model.get('columnSet'),
filterArray: model.getFilterArray(true),
maxRows: maxRows,
pageSize: maxRows,
remoteSort: true
};

Expand Down Expand Up @@ -437,9 +530,12 @@ Ext.define('Connector.view.Grid', {
this.fireEvent('hideload', this);
}

if (rowCount >= maxRows) {
if (rowCount >= maxRows && !this.paging) {
this.showLimitMessage(maxRows);
}

this._updateFooter();

}, this);

return store;
Expand All @@ -449,7 +545,11 @@ Ext.define('Connector.view.Grid', {

var box = this.getBox();
var width = box.width - 27;
var height = box.height - this.headerHeight + 93;
var height;
if (this.paging)
height = box.height - this.headerHeight + 43;
else
height = box.height - this.headerHeight + 93;

return {
width: width,
Expand Down Expand Up @@ -672,6 +772,61 @@ Ext.define('Connector.view.Grid', {
}
},

updatePageNumber: function() {
var store = this.getGrid().getStore();
if (this.footer) {
var page = this.footer.getComponent('grid-page-number');
if (page)
{
page.setValue(store.currentPage);
}
}
},

requestFirstPage: function() {
this.getGrid().getStore().loadPage(1);
this.updatePageNumber();
},

requestPreviousPage: function() {
var store = this.getGrid().getStore();
if (store.currentPage > 1)
{
store.previousPage();
this.updatePageNumber();
}
},

requestNextPage: function() {
var store = this.getGrid().getStore();
if (store.currentPage < Math.ceil(store.totalCount/store.pageSize))
{
store.nextPage();
this.updatePageNumber();
}
},

requestLastPage: function() {
var store = this.getGrid().getStore();
store.loadPage(Math.ceil(store.totalCount/store.pageSize));
this.updatePageNumber();
},

requestPage: function(f,e) {
if (e.getKey() == e.ENTER)
{
var main = this.getBubbleParent().getBubbleParent();
var store = main.getGrid().getStore();

var pageNo = parseInt(this.getValue());
if (pageNo <= Math.ceil(store.totalCount / store.pageSize) && pageNo > 0)
{
store.loadPage(pageNo);
main.updatePageNumber();
}
}
},

showLimitMessage : function(max) {

var msg = 'The app only shows up ' + max + ' rows. Export to see all data.';
Expand Down