Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 2, 2025. It is now read-only.
Discussion options

Hello Community,

I am playing around with Angular Material tabs.
I have a few tabs containing DataTables. When I open a tab, the table is already loaded. However, as soon as I do a search or sorting operation in the table the width of the table adjusts, causing the table content to jump.

I have a small workaround to prevent this jump from occurring when I search within the content upon tab load.

Is there a better way to address this problem or any suggestions to avoid the content from jumping?

onTabOpened($event: MatTabChangeEvent) {
  const tabIndex = $event.index;
  const dataTableMap = [
    {index: 1, dtTrigger: this.locaitonDtApi},
    {index: 2, dtTrigger: this.shellyDevicesApi},
  ];

  const dataTable = dataTableMap.find((item) => item.index === tabIndex);

  if (dataTable) {
    this.dtElements.forEach((element: DataTableDirective) => {
      if (element.dtTrigger === dataTable.dtTrigger) {
        element.dtInstance.then((dtApi) => {
          dtApi.draw(true);
        });
      }
    });
  }
}

Thank you all.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.