We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Panels not resizing when browser is full screen or restored to normal

Hi,

Whenever l click on the sidebar menu button (toggle) to view it in full mode (i.e. maximized state) it does not reflect on the panels on the dashboard component. The panels on the dashboad does not change in size. The grid control on customer component do resize to full mode and normal mode. Kindly assist. https://stackblitz.com/edit/angular-3s6d4b-au8hqo?file=app%2Fcustomer-list%2Fcustomer-list.component.ts,app.component.ts

import { ComponentViewEncapsulationInjectViewChild } from '@angular/core';
import { SidebarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
  selector: 'app-root',
  styleUrls: ['app.component.css'],
  templateUrl: 'app.component.html',
  encapsulation: ViewEncapsulation.None,
})
export class AppComponent {
  @ViewChild('sidebarTreeviewInstance')
  public sidebarTreeviewInstanceSidebarComponent;
  public data: { [keystring]: Object }[] = [
    {
      nodeId: '01',
      nodeText: 'Dashboard',
      iconCss: 'icon-microchip icon',
    },
    {
      nodeId: '02',
      nodeText: 'Customer-List',
      iconCss: 'icon-thumbs-up-alt icon',
    },
  ];

  public widthstring = '230px';
  public targetstring = '.main-sidebar-content';
  public mediaQuerystring = '(min-width: 600px)';

  public fieldsobject;
  constructor(private routerRouter) {
    this.fields = {
      dataSource: this.data,
      id: 'nodeId',
      text: 'nodeText',
      child: 'nodeChild',
      iconCss: 'iconCss',
      selected: 'selected',
    };
  }
  toolbarCliked(): void {
    this.sidebarTreeviewInstance.toggle();
  }

  created() {
    var nodes = this.treeviewInstance.getTreeData();
    for (var i = 0i < nodes.lengthi++) {
      var path = window.location.pathname;
      if (nodes[i].url === path.slice(1path.length - 1)) {
        var item = nodes[i].nodeId;
        var listItems = document.querySelectorAll('.e-list-item');
        for (var i = 0i < listItems.lengthi++) {
          if (listItems[i].classList.contains('e-active')) {
            listItems[i].classList.remove('e-active');
          }
          if (item === listItems[i].getAttribute('data-uid')) {
            //select the corresponding node
            listItems[i].classList.add('e-active');
          }
        }
      }
    }
  }
  public loadRoutingContent(argsNodeSelectEventArgs): void {
    let data1any = this.treeviewInstance.getTreeData(args.node);
    let routerLinkstring = data1[0].url;
    this.router.navigate([routerLink]);
  }

  ngOnInit() {
    this.router.navigate(['dashboard']);
  }

  public onCreated(argsany) {
    this.sidebarTreeviewInstance.element.style.visibility = '';
  }
}


<div class="control-section" id="reswrapper">
<!-- sample level element  -->
<!-- header-section  declaration -->
<div>
    <ejs-toolbar id="resToolbar" (clicked)="toolbarCliked()">
        <e-items>
            <e-item prefixIcon="e-tbar-menu-icon tb-icons" tooltipText="Menu"></e-item>
            <e-item>
                <ng-template #template>
                    <div class="e-folder">
                        <div class="e-folder-name">BE </div>
                    </div>
                </ng-template>
            </e-item>
        </e-items>
    </ejs-toolbar>
</div>
<!-- end of header-section -->
<ejs-sidebar id="sideTree" class="sidebar-treeview" #sidebarTreeviewInstance [width]="width" [target]="target" (created)="onCreated($event)" style="visibility: hidden"
    [mediaQuery]="mediaQuery" [isOpen]="true">
    <div class='main-menu'>
        <div class="table-content">
            <ejs-textbox id="resSearch" placeholder="Search..."></ejs-textbox>
            <p class="main-menu-header">TABLE OF CONTENTS</p>
        </div>
        <div>
            <ejs-treeview id='mainTree' #treeviewInstance cssClass="main-treeview" [fields]="fields" 
            (nodeSelected)="loadRoutingContent($event)" expandOn='Click'>
            </ejs-treeview>
        </div>
    </div>
</ejs-sidebar>
<!-- end of sidebar element -->
<!-- .main-sidebar-content declaration -->
<div class="main-sidebar-content" id="main-text">
    <div class="sidebar-content">
      <router-outlet></router-outlet>
    </div>
</div>
</div>


Regards

Charles


8 Replies

LD LeoLavanya Dhanaraj Syncfusion Team January 25, 2023 05:35 PM UTC

Hi Charles,


Greetings from Syncfusion support.


Based on your shared details, we understand that you are facing an issue with the Dashboard Layout component inside the Sidebar component when performing Sidebar toggle actions. Although we were unable to run your shared sample, we have attempted to replicate the problem by creating a sample based on the your sample code. However, we were unable to replicate the issue(Panels not resizing when browser is full screen or restored to normal) at end. For your reference, we have included the sample.


Sample: https://stackblitz.com/edit/angular-d7kvhn?file=src%2Fapp.component.ts


Please check out the shared sample at your end. However, if we misunderstood your exact issue, please share some additional details related to your exact issue like video footage and sample. This will allow us to fully understand your issue and provide a solution that meets your needs.


Regards,

Leo Lavanya Dhanaraj



CH Charles January 25, 2023 08:50 PM UTC

Hi Leo,


Thank you for your response. From your sample whenever the sidebar is hidden the dashboard layout should be in full screen view i.e. the panels should be wide to fill the space. And when the sidebar is shown the dashboard layout (when in normal view) should also fill the space.

In my sample below the dashboard layout (panels) appear to fill the space in full only when l drag to resize the browser page manually. So l want when l click on the sidebar toggle button it should resize automatic (dashboard layout should fill the space).

https://stackblitz.com/edit/angular-d7kvhn-sstltk?file=src%2Fapp.component.ts,src%2Fapp.component.html

See pictures below how l want the Dashboard Layout component inside the Sidebar component to appear. Kindly assist.

Full screen view (sidebar is hidden)

Full screen view (2).png


Normal view (sidebar is shown)

Normal view (2).png



Regards

Charles



LD LeoLavanya Dhanaraj Syncfusion Team January 27, 2023 05:39 PM UTC

Charles, We would like to mention that the required scenario occurs because the Dashboard Layout initially takes the entire width of the page and renders the panel. The mentioned issue is also occurring due to the component is not being properly refreshed. To overcome the issue, we suggest you to refresh the Dashboard Layout when changing the states of Sidebar(open and change). Check the below mentioned code snippets and sample for your reference. This helps in the proper alignment of panels based on the Sidebar’s width.


Sample : https://stackblitz.com/edit/angular-sidebar-with-dashboard-wwnc8c?file=app.component.ts,app.component.html


<ejs-sidebar

    #dockBar

    id="dockSidebar"

    [enableDock]="enableDock"

    [width]="width"

    [dockSize]="dockSize"

    (open)="onOpen($event)"

    (change)="onChange($event)"

></ejs-sidebar>

 

onOpen() {

  var parentElement = document.getElementById('dashboardParent');

  parentElement.style.width =

    'calc(100% - ' + this.dockBar.element.clientWidth + 'px)';

}

 

onChange() {

  var parentElement = document.getElementById('dashboardParent');

  parentElement.style.width =

    'calc(100% - ' + this.dockBar.element.clientWidth + 'px)';

  this.dashboard.refresh();

}


Follow our suggestion and check the shared sample at your end. Please get back to us if you need any further assistance.


Regards,

Leo Lavanya Dhanaraj



CH Charles January 30, 2023 06:51 PM UTC

Hi Leo,


Thank you for your response. In my sample l was not able to to successfully apply your codes as the sidebar menu are router links. So l want the dashboard layout to fill the space whenever i return to select the dashboard menu from customer menu. kindly assist.

https://stackblitz.com/edit/angular-d7kvhn-otuzdu?file=src%2Fdashboard%2Fdashboard.component.ts,src%2Fapp.component.ts,src%2Fapp.component.html


Regards

charles



LD LeoLavanya Dhanaraj Syncfusion Team March 15, 2023 12:58 PM UTC

Hi Charles,


Thanks for your patience.


To meet your requirement, we have included the modified Angular Dashboard Layout sample. In your sample, you had given the column value of 7, but you have only rendered panels for 6 columns. Therefore, the extra space for panel rendering is allocated in your application. To remove the extra space in the Dashboard Layout, we have set the column value as occupied by the panels in the Dashboard and refreshed the component using its instance inside the Dashboard created event.


Check out the below sample and code snippets for your reference.


Sample : https://stackblitz.com/edit/angular-d7kvhn-58vy9y?file=src%2Fdashboard%2Fdashboard.component.ts,src%2Fapp.component.ts


[dashboard.component.html]

<ejs-dashboardlayout

    id="defaultLayout"

    #defaultLayout

    [columns]="columns"

    [cellSpacing]="cellSpacing"

    [panels]="panels"

    (created)="dashboardCreated($event)"

  >

</ejs-dashboardlayout>

 

[dashboard.component.ts]

@ViewChild('defaultLayout')

public dashboardIns: DashboardLayoutComponent;

 

public columns: number = 6;

 

dashboardCreated() {

  setTimeout(() => {

    this.dashboardIns.refresh();

  }, 500);

}



CH Charles April 24, 2023 03:43 PM UTC

Hi LeoLavanya ,


I have  check out the modified sample and code snippets that you had supplied but yet it didnt meet my requirement. See video attached of the reported issue. Whenever the sidebar panel is in hidden state then the panels on the dashboard component should get resized and filled the screen and when it's switched on normal mode it should resized to fit on the screen. Kindly assist


Regards

Charles


Attachment: Sidebar_dashboard_issue_1d81bd7e.zip


LD LeoLavanya Dhanaraj Syncfusion Team May 9, 2023 06:03 PM UTC

Charles, Currently, we are checking the mentioned Dashboard refreshment issue in the Angular platform. We need some additional time to check this issue and we will update you with further details by May 12, 2023. We appreciate your patience.


Regards,

Leo Lavanya Dhanaraj



LD LeoLavanya Dhanaraj Syncfusion Team May 17, 2023 11:14 AM UTC

Hi Charles,


Thanks for your patience.


Based on your shared sample, we have validated the mentioned Dashboard refreshment issue in the Angular platform. The reported issue occurs because the Dashboard Layout component not being properly refreshed while navigating to another page using the router. To overcome the reported issue, you need to refresh the Dashboard component using the refresh method.


For your reference, we have included the modified sample. Here, we have called the Dashboard refresh method inside the Sidebar open and close events using the router-outlet active event.


Sample : https://stackblitz.com/edit/angular-d7kvhn-pjb9f7?file=src%2Fapp.component.html,src%2Fapp.component.ts,src%2Fdashboard%2Fdashboard.component.ts


[app.component.html]

<div class="control-section" id="reswrapper"> ...

  <ejs-sidebar

    id="sideTree" ...

    (open)="onOpen($event)"

    (close)="onClose($event)"

  >

  ...

  </ejs-sidebar>

  <div class="main-sidebar-content" id="main-text">

    <div class="sidebar-content">

      <router-outlet (activate)="onActivate($event)"></router-outlet>

    </div>

  </div>

</div>

 

[app.component.ts]

private routerCompRef;

public onActivate(componentReference) {

  this.routerCompRef = componentReference;

}

onClose() {

  this.routerCompRef.refreshDashboard();

}

onOpen() {

  this.routerCompRef.refreshDashboard();

}

 

[dashboard.component.ts]

refreshDashboard() {

  if (this.dashboardIns) {

    setTimeout(() => {

      this.dashboardIns.refresh();

    }, 500);

  }

}


Loader.
Live Chat Icon For mobile
Up arrow icon