Skip to content

[data grid] Using initialState with sort, will trigger a onFetchRows function call on first load #13994

Open
@rafael-lopes-rlabs

Description

@rafael-lopes-rlabs

Steps to reproduce

Link to live example: https://codesandbox.io/s/mystifying-neumann-jqrhw2?file=/src/Demo.tsx

Steps:

  1. Remove initialState prop.
  2. Refresh the page and check for console logs
  3. Add back initialState prop
  4. Refresh the page and check for console logs

Current behavior

The onFetchRows function is triggered when the component initially loads if the initialState prop includes a `sort´ configuration. This causes the data to be fetched client-side automatically, instead of following the expected behavior where the initial data is fetched server-side and subsequent data is fetched client-side via lazy loading.

Expected behavior

The onFetchRows function should only be triggered when additional data is needed (scrolling down to load more rows). The initial data should only be fetched server-side.

Context

No response

Your environment

npx @mui/envinfo
  System:
    OS: Linux 6.6 Pop!_OS 22.04 LTS
  Binaries:
    Node: 21.7.1 - /run/user/1000/fnm_multishells/11297_1721987656477/bin/node
    npm: 10.5.0 - /run/user/1000/fnm_multishells/11297_1721987656477/bin/npm
    pnpm: 9.1.1 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 122.0.6261.94
  npmPackages:
    @emotion/react:  11.11.4 
    @emotion/styled:  11.11.5 
    @mui/material: ^5.16.1 => 5.16.4 
    @mui/x-data-grid-premium: ^7.10.0 => 7.10.0 
    react:  18.3.1 

Search keywords: initialState, onFetchRows, sorting
Order ID: 79663

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something doesn't workcomponent: data gridThis is the name of the generic UI component, not the React module!feature: Server integrationBetter integration with backends, e.g. data sourcefeature: SortingRelated to the data grid Sorting featuregood first issueGreat for first contributions. Enable to learn the contribution process.support: commercialSupport request from paid userssupport: premium standardSupport request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions