High Performance Data Grid & UI Components for Angular, React & Blazor Forums Table Anyone familiar with common pitfalls in: Table?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #113491
    linda05
    Participant

    Are there examples of using Smart Table with state management (like Redux, VUEx, etc.)?

    #113545
    admin
    Keymaster

    Hi,

    You can try this:

    React + Redux integration (realistic pattern)
    1. Treat Smart Table as controlled

    <Table
      dataSource={data}
      sortMode="one"
      filterable
      paging
      pageIndex={page}
      pageSize={pageSize}
      onSort={handleSort}
      onFilter={handleFilter}
      onPage={handlePage}
    />

    Wire events, Redux

    const handleSort = (e) => {
      dispatch({
        type: 'SET_SORT',
        payload: e.detail.sortColumns
      });
    };
    
    const handleFilter = (e) => {
      dispatch({
        type: 'SET_FILTER',
        payload: e.detail.filters
      });
    };
    
    const handlePage = (e) => {
      dispatch({
        type: 'SET_PAGE',
        payload: e.detail.pageIndex
      });
    };

    Trigger API calls from state changes

    
    useEffect(() => {
      dispatch(fetchTableData());
    }, [sort, filter, page, pageSize]);

    Fetch with state applied

    export const fetchTableData = () => async (dispatch, getState) => {
      const { sort, filter, page, pageSize } = getState().table;
    
      const query = new URLSearchParams({
        page,
        size: pageSize,
        sort: JSON.stringify(sort),
        filter: JSON.stringify(filter)
      });
    
      const res = await fetch(<code>/api/data?${query}</code>);
      const data = await res.json();
    
      dispatch({ type: 'SET_DATA', payload: data });
    };

    Regards,
    Markov

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.