Skip to content

Commit

Permalink
feat: add ensureIndexVisible
Browse files Browse the repository at this point in the history
add ensureIndexVisible to Ensure the row index is visible by vertically scrolling the grid
and deprecate setVisibleRow
  • Loading branch information
hyyan committed Mar 4, 2020
1 parent 93c4025 commit 196e0f4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
33 changes: 29 additions & 4 deletions BBjGridExWidget.bbj
Expand Up @@ -2084,7 +2084,27 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#executeScript(script$)
methodend
rem /**
rem * Set visible row
rem * Ensures the row index is visible by vertically scrolling the grid
rem *
rem * Ensures the row index is visible by vertically scrolling the grid·
rem * The valid values for positions are {'top', 'middle', 'bottom'}·
rem * If top, middle or bottom, the grid will scroll the row to place the row at top, middle or bottom
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjString key!: the row key
rem * @param BBjString position!: the scrolling position
rem *
rem * @see GRID_ROWPOS_TOP()
rem * @see GRID_ROWPOS_MIDDLE()
rem * @see GRID_ROWPOS_BOTTOM()
rem */
method public void ensureIndexVisible(BBjString key! , BBjString position!)
script$="gw_ensureIndexVisible('" + #GRIDID$ + "','" + str(key!) + "','" + str(position!) +"');"
#executeScript(script$)
methodend
rem /**
rem * Ensures the row index is visible by vertically scrolling the grid
rem *
rem * Ensures the row index is visible by vertically scrolling the grid&#183;
rem * The valid values for positions are {'top', 'middle', 'bottom'}&#183;
Expand All @@ -2099,10 +2119,15 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
rem * @see GRID_ROWPOS_MIDDLE()
rem * @see GRID_ROWPOS_BOTTOM()
rem */
method public void ensureIndexVisible(BBjNumber index! , BBjString position!)
#ensureIndexVisible(str(index!),position!)
methodend
rem /**
rem * @deprecated use ensureIndexVisible instead
rem */
method public void setVisibleRow(BBjNumber index! , BBjString position!)
script$="gw_setVisibleRow('" + #GRIDID$ + "'," + str(index!) + ",'" + str(position!) +"');"
#executeScript(script$)
methodend
#ensureIndexVisible(index!,position!)
methodend
rem /**
rem * Set visible column&#183; Ensures the column is visible, scrolling the table if needed&#183;
rem *
Expand Down
18 changes: 14 additions & 4 deletions client/dist/bbj-grid-widget.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/bbj-grid-widget.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/dist/report.html

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions client/src/api/rows.js
Expand Up @@ -22,9 +22,18 @@ export function gw_expandAll(id) {
export function gw_collapseAll(id) {
gw_getGrid(id).options.api.collapseAll();
}

export function gw_setVisibleRow(id, index, position) {
gw_getGrid(id).options.api.ensureIndexVisible(index, position);
/**
* Ensures the row index is visible by vertically scrolling the grid
*
* @param {String} id the grid's id
* @param {String|Number} index the row index or key
* @param {String} position {'top', 'middle', 'bottom', undefined/null}
*/
export function gw_ensureIndexVisible(id, index, position) {
const api = gw_getGrid(id).options.api;
const rowId = api.getRowNode(index).rowIndex;

api.ensureIndexVisible(rowId, position);
}

export function gw_navigateToNextRow(id, params) {
Expand Down

0 comments on commit 196e0f4

Please sign in to comment.