MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / Table

Function Table

web/pgadmin/static/js/components/PgTable.jsx:107–265  ·  view source on GitHub ↗
({
  columns, data, hasSelectRow, schema, sortOptions, tableProps, searchVal,
  loadNextPage, ...props
})

Source from the content-addressed store, hash-verified

105};
106
107export function Table({
108 columns, data, hasSelectRow, schema, sortOptions, tableProps, searchVal,
109 loadNextPage, ...props
110}) {
111 const { schemaState } = useSchemaState({
112 schema: getTableSchema(schema),
113 getInitData: null,
114 viewHelperProps: {mode: 'properties'},
115 });
116
117 // We don't care about validation in static table, hence - initialising the
118 // data directly.
119 if (data.length && schemaState) {
120 schemaState.initData = schemaState.data = prepareData({'data': data});
121 }
122
123 const defaultColumn = React.useMemo(
124 () => ({
125 size: 150,
126 minSize: 100,
127 maxSize: 1200,
128 }),
129 []
130 );
131
132 const finalColumns = useMemo(() => (hasSelectRow ? [{
133 id: 'selection',
134 header: getCheckboxCell({
135 title: gettext('Select All Rows'),
136 }),
137 cell: getCheckboxHeaderCell({
138 title: gettext('Select Row'),
139 }),
140 enableSorting: false,
141 enableResizing: false,
142 maxSize: 35,
143 }] : []).concat(
144 columns.filter(
145 (c) => _.isUndefined(c.enableVisibility) ? true : c.enableVisibility
146 ).map((c) => ({
147 ...c,
148 // if data is null then global search doesn't work
149 // Use accessorFn to return empty string if data is null.
150 accessorFn: c.accessorFn ?? (
151 c.accessorKey ? (row) => row[c.accessorKey] ?? '' : undefined
152 ),
153 }))
154 ), [hasSelectRow, columns]);
155
156 // Render the UI for your table
157 const tableRef = useRef();
158 let flatData = [];
159 let fetchMoreOnBottomReached;
160 let totalFetched = 0;
161 let totalDBRowCount = 0;
162
163 // Infinite scrolling
164 const { _data, fetchNextPage, isFetching } = useInfiniteQuery({

Callers

nothing calls this directly

Calls 8

useSchemaStateFunction · 0.90
prepareDataFunction · 0.90
getCheckboxCellFunction · 0.90
getCheckboxHeaderCellFunction · 0.90
getTableSchemaFunction · 0.85
gettextFunction · 0.85
loadNextPageFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected