Web Components Tree Grid Toolbar

    The Ignite UI for Web Components Toolbar in is a container for UI operations in the Web Components Tree Grid. The Web Components toolbar is located at the top of the Web Components component, i.e., the IgcTreeGridComponent and it matches its horizontal size. The toolbar container can host any custom content or set of predefined UI controls. The default set for the Web Components Tree Grid includes:

    • 열 숨기기
    • 열 고정
    • 엑셀 내보내기
    • 고급 필터링

    도구 모음과 사전 정의된 UI 구성 요소는 Web Components 이벤트를 지원하고 개발자를 위한 API를 노출합니다.

    Web Components Toolbar Grid Example

    The predefined IgcGridToolbarActionsComponent and IgcGridToolbarTitleComponent UI components are added inside the IgcGridToolbarComponent and this is all needed to have a toolbar providing default interactions with the corresponding Grid features:

    <igc-tree-grid id="treeGrid" primary-key="ID" foreign-key="ParentID" auto-generate="true">
        <igc-grid-toolbar>
            <igc-grid-toolbar-title>Tree Grid Toolbar</igc-grid-toolbar-title>
            <igc-grid-toolbar-actions>
                <igc-grid-toolbar-advanced-filtering><igc-grid-toolbar-advanced-filtering>
                <igc-grid-toolbar-hiding></igc-grid-toolbar-hiding>
                <igc-grid-toolbar-pinning></igc-grid-toolbar-pinning>
                <igc-grid-toolbar-exporter></igc-grid-toolbar-exporter>
            </igc-grid-toolbar-actions>
        </igc-grid-toolbar>
    </igc-tree-grid>
    

    [!Note] As seen in the code snippet above, the predefined Actions UI components are wrapped in the IgcGridToolbarActionsComponent container. This way, the toolbar title is aligned to the left of the toolbar and the actions are aligned to the right of the toolbar.

    물론, 각 UI는 서로 독립적으로 추가될 수도 있고 전혀 추가되지 않을 수도 있습니다. 이렇게 하면 도구 모음 컨테이너가 비어 있게 렌더링됩니다.

    <igc-tree-grid primary-key="ID" foreign-key="ParentID" auto-generate="true">
        <igc-grid-toolbar>
        </igc-grid-toolbar>
    </igc-tree-grid>
    

    각 기본 UI 구성 요소를 포괄적으로 살펴보려면 아래 기능 섹션을 계속 읽어보세요.

    특징

    도구 모음은 그리드 전체에 영향을 미치는 논리/상호 작용을 분리하는 데 유용합니다.

    위에 표시된 대로 그리드에서 데이터 제어, 열 숨기기, 열 고정, 고급 필터링 및 내보내기를 위한 기본 구성 요소를 제공하도록 구성할 수 있습니다.

    이러한 기능은 Ignite UI for Web Components Suite의 카드 구성 요소와 유사한 패턴을 따라 서로 독립적으로 사용하도록 설정할 수 있습니다.

    아래에는 도구 모음의 주요 기능과 각 기능에 대한 예제 코드가 나열되어 있습니다.

    Title

    Setting a title for the toolbar in your grid is achieved by using the IgcGridToolbarTitleComponent.

    사용자는 간단한 텍스트부터 보다 복잡한 템플릿까지 무엇이든 제공할 수 있습니다.

    <igc-grid-toolbar>
        <igc-grid-toolbar-title>Grid toolbar title</igc-grid-toolbar-title>
    </igc-grid-toolbar>
    

    Actions

    The IgcGridToolbarActionsComponent is where users can place actions/interactions in relation to the parent grid. As with the title portion of the toolbar, users can provide anything inside that template part, including the default toolbar interaction components.

    <igc-grid-toolbar>
        <igc-grid-toolbar-actions>
        <!-- ... -->
        </igc-grid-toolbar-actions>
    </igc-grid-toolbar>
    

    열 고정

    The IgcGridToolbarPinningComponent component provides the default UI for interacting with column pinning in the grid.

    구성 요소는 구성 요소 제목, 구성 요소 입력을 위한 자리 표시자 및 드롭다운 자체의 높이와 같은 UI 사용자 정의를 위한 여러 입력 속성뿐만 아니라 도구 모음이 포함된 상위 그리드를 사용하여 즉시 작동하도록 설정됩니다.

    <igc-grid-toolbar>
        <igc-grid-toolbar-actions>
            <igc-grid-toolbar-pinning
                title="Grid pinned columns"
                prompt="Filter column collection"
                column-list-height="400px">
            </igc-grid-toolbar-pinning>
        </igc-grid-toolbar-actions>
    </igc-grid-toolbar>
    

    열 숨기기

    The IgcGridToolbarHidingComponent provides the default UI for interacting with column hiding. Exposes the same input properties for customizing the UI, such as the component title, the placeholder for the component input and the height of the dropdown itself.

    <igc-grid-toolbar>
        <igc-grid-toolbar-actions>
            <igc-grid-toolbar-hiding
                title="Grid column hiding"
                prompt="Filter column collection"
                column-list-height="400px">
            </igc-grid-toolbar-hiding>
        </igc-grid-toolbar-actions>
    </igc-grid-toolbar>
    

    고급 필터링

    도구 모음 고급 필터링 구성 요소는 고급 필터링 기능을 위한 기본 UI를 제공합니다. 구성 요소는 버튼의 기본 텍스트를 변경하는 방법을 노출합니다.

    <igc-grid-toolbar>
        <igc-grid-toolbar-actions>
            <igc-grid-toolbar-advanced-filtering>Custom text for the toggle button</igc-grid-toolbar-advanced-filtering>
        </igc-grid-toolbar-actions>
    </igc-grid-toolbar>
    

    Data Exporting

    As with the rest of the toolbar actions, exporting is provided through a IgcGridToolbarExporterComponent out of the box.

    도구 모음 내보내기 구성 요소는 UI와 내보내기 환경을 모두 사용자 지정하기 위한 여러 입력 속성을 노출합니다.

    These range from changing the display text, to enabling/disabling options in the dropdown to customizing the name of the generated file. For full reference, consult the API documentation for the ToolbarExporter.

    다음은 Web Components 템플릿을 통해 사용자 지정할 수 있는 몇 가지 옵션을 보여주는 스니펫입니다.

    <igc-grid-toolbar>
        <igc-grid-toolbar-actions>
            <igc-grid-toolbar-exporter export-csv="true" export-excel="true" filename="exported_data">
            </igc-grid-toolbar-exporter>
        </igc-grid-toolbar-actions>
    </igc-grid-toolbar>
    

    In addition to changing the exported filename, the user can further configure the exporter options by waiting for the ToolbarExporting event and customizing the options entry in the event properties.

    [!Note] By default when exporting to CSV the exporter exports using a comma separator and uses a '.csv' extension for the output file. You can customize these exporting parameters by subscribing to events of the exporter or changing the values of the exporter options fields. You can also cancel the export process by setting the cancel field of the event args to true.

    다음 코드 조각은 도구 모음 내보내기 이벤트를 구독하고 내보내기 옵션을 구성하는 방법을 보여줍니다.

    <igc-tree-grid id="treeGrid"></igc-tree-grid>
    
    constructor() {
        var treeGrid = document.getElementById('treeGrid') as IgcTreeGridComponent;
        treeGrid.addEventListener("toolbarExporting", this.configureExport);
    }
    
    public configureExport(evt: CustomEvent<IgcGridToolbarExportEventArgs>) {
        const args = evt.detail;
        const options: IgcExporterOptionsBase = args.options;
        if (options) {
            options.fileName = `Report_${new Date().toDateString()}`;
            (args.exporter as any).columnExporting.subscribe((columnArgs: any) => {
                columnArgs.cancel = columnArgs.header === 'Name';
            });
        }
    }
    

    다음 샘플은 내보낸 파일을 사용자 정의하는 방법을 보여줍니다.

    Exporting Indicator

    기본 도구 모음 내보내기 구성 요소를 사용하는 경우 내보내기 작업이 발생할 때마다 작업이 진행되는 동안 도구 모음에 진행률 표시기가 표시됩니다.

    Moreover, users can set the toolbar showProgress property and use for their own long running operations or just as another way to signify an action taking place in the grid.

    아래 샘플에는 진행률 표시줄을 볼 수 있도록 데이터 내보내기에 필요한 시간을 늘리기 위해 상당한 양의 데이터가 사용됩니다. 또한 그리드에서 장기 실행 작업을 시뮬레이션하는 또 다른 버튼이 있습니다.

    Custom Content

    도구 모음 구성 요소의 작업 부분이 특정 사용 사례에 충분하지 않은 경우 도구 모음 자체에는 사용자가 추가 UI를 제공할 수 있는 일반 콘텐츠 프로젝션이 있습니다. 사용자가 API 호출 또는 바인딩을 위해 해당 그리드 인스턴스가 필요한 경우 템플릿 참조 변수를 만들 수 있습니다.

    다음은 샘플 스니펫입니다.

    <igc-tree-grid id="grid">
        <igc-grid-toolbar>
            <igc-grid-toolbar-title>title</igx-grid-toolbar-title>
            <!--
                Everything between the toolbar tags except the default toolbar components/directives
                will be projected as custom content.
             -->
            <igc-grid-toolbar-actions>
            </igc-grid-toolbar-actions>
        </igc-grid-toolbar>
    </igc-tree-grid>
    

    다음 샘플은 열 헤더를 클릭하여 정렬 설정을 지우기 위해 도구 모음에 추가 버튼을 추가하는 방법을 보여줍니다.

    Styling

    사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.

    <igc-tree-grid class="grid"></igc-tree-grid>
    

    그런 다음 해당 클래스에 대한 관련 CSS 속성을 설정합니다.

    .grid {
        --ig-grid-toolbar-background-color: #2a2b2f;
        --ig-grid-toolbar-title-text-color: #ffcd0f;
        --ig-grid-toolbar-dropdown-background: #2a2b2f;
    }
    

    Demo

    API References

    Grid Toolbar 서비스에는 아래에 나열된 몇 가지 API가 더 있습니다.

    IgcTreeGridComponent Events:

    • ToolbarExporting

    Additional Resources

    우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.