當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Utils.iterateObject方法代碼示例

本文整理匯總了TypeScript中ag-grid/main.Utils.iterateObject方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Utils.iterateObject方法的具體用法?TypeScript Utils.iterateObject怎麽用?TypeScript Utils.iterateObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ag-grid/main.Utils的用法示例。


在下文中一共展示了Utils.iterateObject方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: recursivelyAddGroup

    // parentChildren - the list of colDefs we are adding to
    // @index - how far the column is from the top (also same as pivotKeys.length)
    // @uniqueValues - the values for which we should create a col for
    // @pivotKeys - the keys for the pivot, eg if pivoting on {Language,Country} then could be {English,Ireland}
    private recursivelyAddGroup(parentChildren: (ColGroupDef|ColDef)[], pivotColumnDefs: ColDef[], index: number, uniqueValues: any,
                                pivotKeys: string[], columnIdSequence: NumberSequence, levelsDeep: number): void {

        Utils.iterateObject(uniqueValues, (key: string, value: any)=> {

            var newPivotKeys = pivotKeys.slice(0);
            newPivotKeys.push(key);

            var createGroup = index !== levelsDeep;
            if (createGroup) {
                var groupDef: ColGroupDef = {
                    children: [],
                    headerName: key
                };
                parentChildren.push(groupDef);
                this.recursivelyAddGroup(groupDef.children, pivotColumnDefs, index+1, value, newPivotKeys, columnIdSequence, levelsDeep);
            } else {

                var measureColumns = this.columnController.getAggregationColumns();
                var valueGroup: ColGroupDef = {
                    children: [],
                    headerName: key
                };
                parentChildren.push(valueGroup);
                measureColumns.forEach( measureColumn => {
                    var colDef = this.createColDef(measureColumn, measureColumn.getColDef().headerName, newPivotKeys, columnIdSequence);
                    valueGroup.children.push(colDef);
                    pivotColumnDefs.push(colDef);
                });
                valueGroup.children.sort(this.headerNameComparator.bind(this));

            }
            parentChildren.sort(this.headerNameComparator.bind(this));
        });
    }
開發者ID:ycmag,項目名稱:ag-grid-enterprise,代碼行數:39,代碼來源:pivotColDefService.ts

示例2: recursivelyAddGroup

    // parentChildren - the list of colDefs we are adding to
    // @index - how far the column is from the top (also same as pivotKeys.length)
    // @uniqueValues - the values for which we should create a col for
    // @pivotKeys - the keys for the pivot, eg if pivoting on {Language,Country} then could be {English,Ireland}
    private recursivelyAddGroup(parentChildren: (ColGroupDef|ColDef)[], pivotColumnDefs: ColDef[], index: number, uniqueValues: any,
                                pivotKeys: string[], columnIdSequence: NumberSequence, levelsDeep: number): void {

        Utils.iterateObject(uniqueValues, (key: string, value: any)=> {

            var newPivotKeys = pivotKeys.slice(0);
            newPivotKeys.push(key);

            var createGroup = index !== levelsDeep;
            if (createGroup) {
                var groupDef: ColGroupDef = {
                    children: [],
                    headerName: key
                };
                parentChildren.push(groupDef);
                this.recursivelyAddGroup(groupDef.children, pivotColumnDefs, index+1, value, newPivotKeys, columnIdSequence, levelsDeep);
            } else {

                var measureColumns = this.columnController.getNonDefaultAggregationColumns();
                var valueGroup: ColGroupDef = {
                    children: [],
                    headerName: key
                };
                parentChildren.push(valueGroup);
                // if no value columns selected, then we insert one blank column, so the user at least sees columns
                // rendered. otherwise the grid would render with no columns (just empty groups) which would give the
                // impression that the grid is broken
                if (measureColumns.length===0) {
                    // this is the blank column, for when no value columns enabled.
                    var colDef = this.createColDef(null, '-', newPivotKeys, columnIdSequence, `'n/a'`);
                    valueGroup.children.push(colDef);
                    pivotColumnDefs.push(colDef);
                } else {
                    measureColumns.forEach( measureColumn => {
                        var colDef = this.createColDef(measureColumn, measureColumn.getColDef().headerName, newPivotKeys, columnIdSequence, null);
                        valueGroup.children.push(colDef);
                        pivotColumnDefs.push(colDef);
                    });
                }
                valueGroup.children.sort(this.headerNameComparator.bind(this));

            }
            parentChildren.sort(this.headerNameComparator.bind(this));
        });
    }
開發者ID:tloten,項目名稱:ag-grid-enterprise,代碼行數:49,代碼來源:pivotColDefService.ts


注:本文中的ag-grid/main.Utils.iterateObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。