Skip to content

LocalListScrollingDataSource move / page to record #1059

@howudodat

Description

@howudodat

Is your feature request related to a problem? Please describe.
I have bi-directional binding from my table to an open layers map. When a user clicks on an icon in the map, it should find the row in the table, page to it and highlight the row

Describe the solution you'd like
A method to make sure that the table is paged to a particular row

Describe alternatives you've considered
Switching to a paged table. My users like the clean look of the scrolling table

Additional context
Here is code that does it:

	public void moveToRecord(T record) {
		int index = filtered.indexOf(record);
		if (index >= 0) {
			boolean append = index >= pageSize * (pageIndex + 1);
			if (append) {
				int fromIndex = pageSize * (pageIndex + 1); // current end of records
				pageIndex = index / pageSize; // calculate the new page index
				int endIndex = ((pageIndex+1) * pageSize);
				final int toIndex = Math.min(endIndex, filtered.size());
				listeners.forEach(dataChangeListener -> dataChangeListener
						.onDataChanged(new DataChangedEvent<>(new ArrayList<>(filtered.subList(fromIndex, toIndex)), append, filtered.size())));
			}
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions