Skip to content

Commit

Permalink
Merge pull request #259 from material-table-core/data_id
Browse files Browse the repository at this point in the history
Data Id
  • Loading branch information
Domino987 committed Jul 19, 2021
2 parents 5c01bab + 0a02ff2 commit faa4c5a
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 14,149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function EditableTable() {
}
]);

const [data, setData] = useState([{ date: new Date() }]);
const [data, setData] = useState([{ date: new Date(), id: 0 }]);

return (
<MaterialTable
Expand Down
4 changes: 2 additions & 2 deletions __tests__/demo/demo-components/RemoteData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function I1941() {
.then((response) => response.json())
.then((result) => {
resolve({
data: result.data,
data: result.data.map((d, i) => ({ ...d, id: i })),
page: result.page - 1,
totalCount: result.total
});
Expand Down Expand Up @@ -215,7 +215,7 @@ export function I122() {
.then((response) => response.json())
.then((result) => {
resolve({
data: result.data,
data: result.data.map((d, i) => ({ ...d, id: i })),
page: result.page - 1,
totalCount: result.total
});
Expand Down
39 changes: 26 additions & 13 deletions __tests__/demo/demo-components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ import MaterialTable, { MTableBodyRow, MTableEditRow } from '../../../src'; // r
export { default as EditableRowDateColumnIssue } from './EditableRowDateColumnIssue';

const global_data = [
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 }
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63, id: 0 },
{
name: 'Zerya Betül',
surname: 'Baran',
birthYear: 2017,
birthCity: 34,
id: 1
}
];

const global_data_CustomExport = [
Expand All @@ -15,14 +21,16 @@ const global_data_CustomExport = [
surname: 'Baran',
birthYear: 1987,
birthCity: 63,
teams: ['Team A', 'Team B']
teams: ['Team A', 'Team B'],
id: 0
},
{
name: 'Zerya Betül',
surname: 'Baran',
birthYear: 2017,
birthCity: 34,
teams: ['Team C', 'Team D', 'Team E']
teams: ['Team C', 'Team D', 'Team E'],
id: 1
}
];

Expand All @@ -39,8 +47,8 @@ const global_cols = [

export function BulkEdit() {
const [data, setData] = useState([
{ name: 'joe', id: 1, age: 0, x: 'y' },
{ name: 'nancy', id: 2, age: 1, x: 'b' }
{ name: 'joe', id: 1, age: 0, x: 'y', id: 0 },
{ name: 'nancy', id: 2, age: 1, x: 'b', id: 1 }
]);

const [columns] = useState([
Expand Down Expand Up @@ -80,8 +88,8 @@ export function BulkEdit() {

export function BulkEditWithDetailPanel() {
const [data, setData] = useState([
{ name: 'joe', id: 1, age: 0, x: 'y' },
{ name: 'nancy', id: 2, age: 1, x: 'b' }
{ name: 'joe', id: 1, age: 0, x: 'y', id: 0 },
{ name: 'nancy', id: 2, age: 1, x: 'b', id: 1 }
]);

const [columns] = useState([
Expand Down Expand Up @@ -265,9 +273,7 @@ const global_cols = [
* Basic demo that shows a single detail panel, in this case a youtube vid
*/
export function Basic() {
return (
<MaterialTable title="Basic" columns={global_cols} data={global_data} />
);
return <MaterialTable title="Basic" columns={global_cols} data={data} />;
}

export function BasicRef() {
Expand Down Expand Up @@ -566,12 +572,19 @@ export function DefaultOrderIssue(props) {
}
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{
name: 'Mehmet',
surname: 'Baran',
birthYear: 1987,
birthCity: 63,
id: 0
},
{
name: 'Zerya Betül',
surname: 'Baran',
birthYear: 2017,
birthCity: 34
birthCity: 34,
id: 1
}
]}
options={{
Expand Down
3 changes: 0 additions & 3 deletions __tests__/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ module.hot.accept();

render(
<div>
<h1>EditableRowDateColumnIssue</h1>
<EditableRowDateColumnIssue />

<h1>Basic</h1>
<Basic />

Expand Down
Loading

0 comments on commit faa4c5a

Please sign in to comment.