Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to setCellValues in unbound columns? ReactGrid vs DataGrid #2125

Closed
1 of 3 tasks
dnbr2002 opened this issue Jun 27, 2019 · 5 comments
Closed
1 of 3 tasks
Assignees
Labels
Grid The DevExtreme Reactive Grid component question

Comments

@dnbr2002
Copy link

I'm using ...

  • React Grid
  • React Chart
  • React Scheduler

Description

I'm sort of wondering which solution I am supposed to be using at this point. I had started with React Grid. It has been great but the last thing I need is a unbound column where I simply rank/count the rows in this unbound column starting with first row getting the #1, second row #2 and so on. It will be the ranking of the sort I put on the table. I want to display this quite simply. I see here in the Javascript docs for DataGrid you can do this
https://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Configuration/columns/#calculateCellValue

But I can't find this for the React Grid. And now I'm kind of confused why I even started with React Grid, It almost looks like you can do more with DataGrid than the React Grid. So which should I be using. Did I miss how to set a cell value in a unbound column in React Grid Docs? If not will this be added to the React Grid or should I just change my whole table over to DataGrid? Not sure about the decision tree on React Grid vs DataGrid but if React Grid is something your sticking with seems like setting cell values would be an important feature. Hoping I just missed it. Tables have been great! Thanks

@dnbr2002
Copy link
Author

dnbr2002 commented Jun 27, 2019

Basically I want to do use IDs as seen here.
https://devexpress.github.io/devextreme-reactive/react/grid/docs/guides/editing/#controlled-mode

But I get warnings in console

The row id is undefined. Check the getRowId function.

When using

const getRowId = row => row.id

Which makes sense because my row does not have index values stored in the object such as 0, 1, 2 etc.

If the table was returning the index from the mapped row I could easily get it but it doesn't seem to be there. Also in the example you create your rows differently with the generateRows function.

      rows: generateRows({
        columnValues: { id: ({ index }) => index, ...defaultNestedColumnValues },
        length: 8,
      }),

My data is coming from a prop in React, Not a function pulling in local data. The Array of objects is set. Don't think I can tap on a the id like you are doing here in the table component....

@MaximKudriavtsev MaximKudriavtsev self-assigned this Jun 28, 2019
@MaximKudriavtsev MaximKudriavtsev added Grid The DevExtreme Reactive Grid component question labels Jun 28, 2019
@MaximKudriavtsev
Copy link
Contributor

MaximKudriavtsev commented Jun 28, 2019

Hi @dnbr2002,

The Reactive Grid has the getCellValue property to calculate a custom column value; see the following sample.

As for the getRowId function, you should define a unique id field for data of each row. For example, you may use Array.prototype.map to achieve it.

Also, you can find differences between DevExtreme Reactive Grid and DevExtrrreme DataGrid in the following blog post.

@dnbr2002
Copy link
Author

That is a great getCellValue example! I needed that. Regarding unique Id field, I have one, it's just not what I would use as a ranking number in the column. I think I have found a way to set it before the remote data gets to the table now, this will also make my ranks more global if I want to use it anywhere else. Blog post is just what I was looking for the difference. Thanks for the links! Great help.

@MaximKudriavtsev
Copy link
Contributor

You are welcome!

@lock
Copy link

lock bot commented Jul 12, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Grid The DevExtreme Reactive Grid component question
Projects
None yet
Development

No branches or pull requests

2 participants