Angular Slickgrid 예제 24에서 Angular slickgrid 및 ngfor를 사용하여 동적으로 탭 만들기 (Dynamically create tabs with Angular slickgrid and ngfor in Angular Slickgrid Example 24)


문제 설명

Angular Slickgrid 예제 24에서 Angular slickgrid 및 ngfor를 사용하여 동적으로 탭 만들기 (Dynamically create tabs with Angular slickgrid and ngfor in Angular Slickgrid Example 24)

Angular Slickgrid의 예제 24와 유사한 탭이 있는 페이지가 필요합니다. , 여기서 각 탭의 내용은 그리드입니다. 탭의 수는 다양할 수 있으므로 동적으로 만들어야 합니다.

그래서 예제를 바탕으로 무엇을 해야 할지 알아냈습니다. 먼저 ngOnInit을 수정했습니다.

ngOnInit(): void {
  this.defineGrid1();
  this.defineGrid2();

  // mock some data (different in each dataset)
  this.dataset1 = this.mockData();

  // load data with Http‑Client
 this.http.get((URL_CUSTOMERS)).subscribe((data: any[]) => this.dataset2 = data);

 this.gridOptions3 = this.gridOptions1;
 this.columnDefinitions3 = this.columnDefinitions1;
 this.dataset3 = this.mockData();

  this.paras = [
       {tab:"tab1x", grName:"grid1", cD: this.columnDefinitions1, gO: this.gridOptions1, dS: this.dataset1},
       {tab:"tab2x", grName:"grid2", cD: this.columnDefinitions2, gO: this.gridOptions2, dS: this.dataset2},
       {tab:"tab3x", grName:"grid3", cD: this.columnDefinitions3, gO: this.gridOptions3, dS: this.dataset3}
  ];
}

템플릿에서 *ngFor와 함께 개체를 사용했습니다.

<tabset>
  <div *ngFor="let obj of paras; let i = index">
    <tab [heading]="obj.grName" [id]="obj.tab">
      <h4>Grid {{ i + 1 }} ‑ Load Local Data</h4>
      <angular‑slickgrid
        [gridId]="obj.grName"
        [columnDefinitions]="obj.cD"
        [gridOptions]="obj.gO"
        [dataset]="obj.dS"
      >
      </angular‑slickgrid>
    </tab>
  </div>
</tabset>

3개의 탭을 가져오는 대신 각 탭에 단일 grid, 동일한 내용을 가진 3개의 탭을 얻었습니다. 각 탭에는 3개의 그리드가 모두 포함되어 있습니다.

잘못이 어디 있습니까? 감사합니다


참조 솔루션

방법 1:

As proposed by Raphael I replaced tabset with the Nav directives.

After installing ng‑bootstrap according to the instructions https://ng‑bootstrap.github.io/#/getting‑started#installation

the following ng‑bootstrap‑example based code in the template did the job

<ul ngbNav #nav="ngbNav" class="nav‑tabs">
    <ng‑container ngbNavItem *ngFor="let obj of paras; let i = index">
        <a ngbNavLink>{{obj.grName}}</a>
        <ng‑template ngbNavContent>
        <angular‑slickgrid [gridId]="obj.grName"
            [columnDefinitions]="obj.cD"
            [gridOptions]="obj.gO"
            [dataset]="obj.dS">
        </angular‑slickgrid>
        {{obj.grName}}
      </ng‑template>
    </ng‑container>
</ul>
<div [ngbNavOutlet]="nav" class="mt‑2"></div>

Thanks Raphael and Ghislain for your comments!

(by user15730368user15730368)

참조 문서

  1. Dynamically create tabs with Angular slickgrid and ngfor in Angular Slickgrid Example 24 (CC BY‑SA 2.5/3.0/4.0)

#tabs #ngfor #angular-slickgrid #angular






관련 질문

양식 제출 후 현재 탭 유지 (Keeping the current tabs after submitting the form)

슬라이드다운 탭이 예상대로 작동하지 않음 (Slide-down tabs not working as expected)

일부 장치 Android에서 ViewPager가 작동하지 않음 (ViewPager not working on some devices Android)

ScrollView가 조각에서 작동하지 않습니다 (ScrollView doesn't work in fragment)

공백이 많은 줄을 읽고 출력에서 유지 (Reading lines with a lot of spaces and maintaining them in output)

Google지도 조각을 찾을 수 없습니다 (Can't find google maps fragment)

kaldi 설치 시 libmkl_tbb_thread.so sth 관련 문제 (A problem related to libmkl_tbb_thread.so sth when installing kaldi)

링크 클릭 시 새 탭 또는 창에서 특정 링크 열기 (Open specific link in new tab or window on link clicking)

Vue.js uiv 라이브러리의 Tab 구성 요소에 대한 클래스를 설정하는 방법은 무엇입니까? (How to set up classes for Vue.js uiv library's Tab component?)

Foundation 탭이 초기화되었는지 확인하는 방법은 무엇입니까? (How to check if Foundation tabs are initialized?)

고유 참조가 없는 한 HTML 페이지의 여러 탭(ID 또는 클래스 없음) (Multiple tabs in one HTML page without unique reference (no ID or class))

Angular Slickgrid 예제 24에서 Angular slickgrid 및 ngfor를 사용하여 동적으로 탭 만들기 (Dynamically create tabs with Angular slickgrid and ngfor in Angular Slickgrid Example 24)







코멘트