amaannawab923 commented on code in PR #35343:
URL: https://github.com/apache/superset/pull/35343#discussion_r2414338610
##########
superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.jsx:
##########
@@ -378,20 +392,139 @@ const Chart = props => {
slice_id: slice.slice_id,
is_cached: isCached,
});
+
+ let ownState = dataMask[props.id]?.ownState || {};
+
+ // For AG Grid tables, convert AG Grid state to backend-compatible format
+ if (slice.viz_type === 'ag-grid-table' && chartStates[props.id]?.state) {
+ const agGridState = chartStates[props.id].state;
+
+ // Convert AG Grid sortModel to backend sortBy format
+ if (agGridState.sortModel && agGridState.sortModel.length > 0) {
+ const sortItem = agGridState.sortModel[0];
+ ownState = {
+ ...ownState,
+ sortBy: [
+ {
+ id: sortItem.colId,
+ key: sortItem.colId,
+ desc: sortItem.sort === 'desc',
+ },
+ ],
+ };
+ }
+
+ // Store column order for backend processing
+ if (agGridState.columnState && agGridState.columnState.length > 0) {
+ ownState = {
+ ...ownState,
+ columnOrder: agGridState.columnState.map(col => col.colId),
+ };
+ }
+
+ if (
+ agGridState.filterModel &&
+ Object.keys(agGridState.filterModel).length > 0
+ ) {
+ const agGridFilters = [];
+
+ Object.keys(agGridState.filterModel).forEach(colId => {
+ const filter = agGridState.filterModel[colId];
+
+ // Text filter
+ if (filter.filterType === 'text' && filter.filter) {
+ const clause = {
+ expressionType: 'SIMPLE',
+ subject: colId,
+ operator:
+ filter.type === 'equals'
+ ? '=='
+ : filter.type === 'notEqual'
+ ? '!='
+ : filter.type === 'contains'
+ ? 'ILIKE'
+ : filter.type === 'notContains'
+ ? 'NOT ILIKE'
+ : filter.type === 'startsWith'
+ ? 'ILIKE'
+ : filter.type === 'endsWith'
+ ? 'ILIKE'
+ : 'ILIKE',
+ comparator:
+ filter.type === 'contains' || filter.type === 'notContains'
+ ? `%${filter.filter}%`
+ : filter.type === 'startsWith'
+ ? `${filter.filter}%`
+ : filter.type === 'endsWith'
+ ? `%${filter.filter}`
+ : filter.filter,
+ };
+ agGridFilters.push(clause);
+ } else if (
+ filter.filterType === 'number' &&
+ filter.filter !== undefined
+ ) {
+ const clause = {
+ expressionType: 'SIMPLE',
+ subject: colId,
+ operator:
+ filter.type === 'equals'
+ ? '=='
+ : filter.type === 'notEqual'
+ ? '!='
+ : filter.type === 'lessThan'
+ ? '<'
+ : filter.type === 'lessThanOrEqual'
+ ? '<='
+ : filter.type === 'greaterThan'
+ ? '>'
+ : filter.type === 'greaterThanOrEqual'
+ ? '>='
+ : '==',
+ comparator: filter.filter,
+ };
+ agGridFilters.push(clause);
+ } else if (
+ filter.filterType === 'set' &&
+ Array.isArray(filter.values) &&
+ filter.values.length > 0
+ ) {
+ const clause = {
+ expressionType: 'SIMPLE',
+ subject: colId,
+ operator: 'IN',
+ comparator: filter.values,
+ };
+ agGridFilters.push(clause);
Review Comment:
Why are we creating a simple clause expression, extra form data.filters
should be fine as we handled the search query
--
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]