amaannawab923 commented on code in PR #33357:
URL: https://github.com/apache/superset/pull/33357#discussion_r2081812301
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -198,10 +246,46 @@ export default typedMemo(function DataTable<D extends
object>({
globalFilter: defaultGlobalFilter,
sortTypes,
autoResetSortBy: !isEqual(columnNames, previousColumnNames),
+ manualSortBy: !!serverPagination,
...moreUseTableOptions,
},
...tableHooks,
);
+
+ const handleSearchChange = useCallback(
+ (query: string) => {
+ if (manualSearch && onSearchChange) {
+ onSearchChange(query);
+ } else {
+ setGlobalFilter(query);
+ }
+ },
+ [manualSearch, onSearchChange, setGlobalFilter],
+ );
+
+ // updating the sort by to the own State of table viz
+ useEffect(() => {
+ const serverSortBy = serverPaginationData?.sortBy || [];
+
+ if (serverPagination && !isEqual(sortBy, serverSortBy)) {
+ if (Array.isArray(sortBy) && sortBy.length > 0) {
+ const [sortByItem] = sortBy;
+ const matchingColumn = columns.find(col => col?.id === sortByItem?.id);
+
+ if (matchingColumn && 'columnKey' in matchingColumn) {
+ const sortByWithColumnKey: SortByItem = {
+ ...sortByItem,
+ key: (matchingColumn as { columnKey: string }).columnKey,
+ };
+
+ handleSortByChange([sortByWithColumnKey]);
+ }
+ } else {
+ handleSortByChange([]);
+ }
+ }
+ }, [sortBy]);
+
Review Comment:
useEffect for updating the sortBy state in redux of the table viz &
triggering query to get the latest data based on sortBy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]