Is it possible to disable default sorting in React Admin?

Viewed 6125

I have simple question

Is it possible to disable default sorting by column id? Or at least change it globally?

Thanks for answer

EDIT:

To be more specific, I have REST API (OData) which returns "Id" instead of "id" so I have to set sort everytime I use related component to prevent undefined errors.

I would welcome option to disable default sort in related components.

1 Answers

If you are looking for a solution to disable sort option for that column, you can use sortable={false}.

Example usage:

import React from 'react';
import { List, Datagrid, TextField } from 'react-admin';

export const PostList = (props) => (
<List {...props}>
    <Datagrid>
        <TextField source="id" sortable={false} />
        <TextField source="title" />
        <TextField source="body" />
    </Datagrid>
</List>
);

Or you can specify a default sort for the List.

export const PostList = (props) => (
    <List {...props} sort={{ field: 'published_at', order: 'DESC' }}>
    ...
    </List>
);
Related