MCPcopy Create free account
hub / github.com/grid-js/gridjs / setSort

Method setSort

src/header.ts:107–132  ·  view source on GitHub ↗
(
    sortConfig: GenericSortConfig | boolean,
    columns?: OneDArray<TColumn>,
  )

Source from the content-addressed store, hash-verified

105 }
106
107 private setSort(
108 sortConfig: GenericSortConfig | boolean,
109 columns?: OneDArray<TColumn>,
110 ): void {
111 const cols = columns || this.columns || [];
112
113 for (const column of cols) {
114 // sorting can only be enabled for columns without any children
115 if (column.columns && column.columns.length > 0) {
116 column.sort = undefined;
117 } else if (column.sort === undefined && sortConfig) {
118 column.sort = {};
119 } else if (!column.sort) {
120 // false, null, etc.
121 column.sort = undefined;
122 } else if (typeof column.sort === 'object') {
123 column.sort = {
124 ...column.sort,
125 };
126 }
127
128 if (column.columns) {
129 this.setSort(sortConfig, column.columns);
130 }
131 }
132 }
133
134 private setResizable(resizable: boolean, columns?: OneDArray<TColumn>): void {
135 const cols = columns || this.columns || [];

Callers 1

createFromConfigMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected