public constructor()

in packages/tablesorter-powerbi/src/TableSorterVisual.ts [176:226]


    public constructor(
        options: VisualConstructorOptions,
        initialSettings?: ITableSorterSettings,
        private userInteractionDebounce = 100,
        private defaultPrecision = undefined) { // tslint:disable-line
        this.host = options.host;
        this.initialSettings = merge({
            presentation: {
                numberFormatter: (numVal: number, row: any, col: any) => {
                    const colName = col && col.column && col.column.column;
                    const actualVal = colName && row[colName];
                    if (colName && (actualVal === null || actualVal === undefined)) { // tslint:disable-line
                        numVal = actualVal;
                    }
                    return this.numberFormatter.format(numVal);
                },
                cellFormatter: this.cellFormatter.bind(this),
            },
        }, initialSettings || {});

        this.element = $(`<div><div class="lineup"></div></div>`);

        const className = CSS_MODULE && CSS_MODULE.locals && CSS_MODULE.locals.className;
        if (className) {
            this.element.append($(`<style>${CSS_MODULE}$</style>`));
            this.element.addClass(className);
        }

        this.numberFormatter = formatting.valueFormatter.create({
            value: 0,
            format: "0",
            precision: this.defaultPrecision,
        });
        this.selectionManager = this.host.createSelectionManager();
        this.tableSorter = new TableSorter(this.element.find(".lineup"), undefined, this.userInteractionDebounce);
        this.tableSorter.settings = this.initialSettings;
        this.listeners = [
            this.tableSorter.events.on("selectionChanged", (rows: ITableSorterVisualRow[]) => this.onSelectionChanged(rows)),
            this.tableSorter.events.on(TableSorter.EVENTS.CLEAR_SELECTION, () => this.onSelectionChanged()),
            this.tableSorter.events.on(TableSorter.EVENTS.LOAD_LINEUP, () => {
                // We use this.tableSorter.data where because this data is after it has been sorted/filtered...
                updateRankingColumns(this._data.rankingInfo, this.tableSorter.data);
            }),
            this.tableSorter.events.on("configurationChanged", (config: any) => {
            if (!this.handlingUpdate) {
                this.configurationUpdater();
            }
        })];

        options.element.appendChild(this.element[0]);
    }