import { Component, Input, Output, ViewChild, EventEmitter, ViewEncapsulation, OnInit, OnChanges, AfterViewInit, NO_ERRORS_SCHEMA } from '@angular/core';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RdComponent } from '../../base/rdComponent';
import { L10n } from '@syncfusion/ej2-base';
import {
TreeGridModule, TreeGridComponent, ToolbarService, EditService, ResizeService,
ExcelExportService, PdfExportService, FilterService, CommandColumnService, SortService,
} from '@syncfusion/ej2-angular-treegrid';
export type TreeGridToolbarItem = 'Add' | 'Edit' | 'Update' | 'Delete' | 'Cancel' | 'Search' | 'ExpandAll' | 'CollapseAll' | 'ExcelExport' | 'PdfExport';
export type TreeGridColumnEditType = 'stringedit' | 'numericedit' | 'datepickeredit' | 'dropdownedit' | 'booleanedit' | "";
export interface IColumns {
field: string,
headerText: string,
isPrimaryKey: boolean,
validationRules: object,
edit: object,
editType: TreeGridColumnEditType,
format: string,
width: number | string,
type: any,
displayAsCheckBox: boolean,
valueAccessor: any
}
@Component({
selector: 'rd-tree-grid',
template: `
`,
providers: [ToolbarService, EditService, ExcelExportService, PdfExportService, FilterService, CommandColumnService, ResizeService, SortService],
styleUrls: ["../../css/material.css"],
encapsulation: ViewEncapsulation.None
})
export class TreeGrid extends RdComponent implements OnInit, OnChanges, AfterViewInit {
/**
* --- ValidationRules ---
* requiredRule = { required: true }
dateRule = { date: true }
numericRule = { number: true }
* --- Edit ---
* numericParams = { params: { format: 'n' | 'M/d/y hh:mm a' } }
*
* --- Format ---
* format = { format: 'M/d/y hh:mm a', type: 'dateTime' } || 'yMd'
*
* --- Events ---
* (expanded), (dataBound)
*/
@Input("rd-data") data = [];
@Input("rd-child-path") childPath: string;
@Input("rd-custom-fields") customFields: Object = {};
// Update,Cancel - You can save or discard changes by click toolbar Update and Cancel button respectively
@Input("rd-toolbar") toolbar: Array = ['ExcelExport', 'PdfExport', 'ExpandAll', 'CollapseAll', 'Search', 'Add', 'Delete', 'Edit', 'Update', 'Cancel'];
@Input("rd-edit-settings") editSettings: Object = { allowAdding: true, allowEditing: true, allowDeleting: true, mode: 'Row', newRowPosition: 'Child' };
@Input("rd-filter-settings") filterSettings = { type: "Menu" };
@Input("rd-hidden-columns") hiddenColumns = []; // field
@Input("rd-height") height = (window.innerHeight * .6);
// default -> (v-17.4.49)
// particular ->
// @Input("rd-frozen-column-index") frozenColumnEndIndex = 0; // columnIndex
@Input("rd-columns") columns: Array = [{
field: "", headerText: "", isPrimaryKey: false, validationRules: {}, edit: {},
editType: "", format: "", width: "", type: "", displayAsCheckBox: false, valueAccessor: () => { }
}];
@Input("rd-operations") operations: Array