AllenFang / AllenFang/react-bootstrap-table

Cannot edit on iterated table?

Abierto
#1,467 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
2.2k
Forks
761
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I am having trouble with editing cells inside array iteration.

Let me explain what I mean. If I do something like this, it works fine. `this.props.students` is an array of objects:


ID
Name
Grade

The data that I am actually trying to display is a little more complex. Each student is associated with several scores. I have another array named scores. To display both data at once, I created an object consisting of a name and array of scores. Something like this (not exactly, but you get the idea:

`studentArr = {albert: [{id: 1, score: 10, week: 1}, {id: 2, score: 11, week: 2}],
toni: [{id: 3, score: 9, week: 1}, {id: 4, score: 0, week: 2}]}`

To display it, I had to do the following:

```
...
const cellEditProp = {
mode: 'click'
};

export default...
render(){
const bsTable = [];
if(Object.keys(this.props.studentsScores).length > 0) {
for(var i = 0; i < Object.keys(this.props.studentsScores).length; i++){
bsTable.push(


{Object.keys(this.props.studentsScores)[i]}



ID
Week
Point


)
}
};
return(

{bsTable}
...

```

In short, the code above displays all X students and its associated scores.

However, when I tried to edit it, although when I click on the cell, it displays the prompt to edit the cell, but after I pressed Return/ Enter, it reverts back to the previous value. In short, the edit did not persist on that page.

![screen shot 2017-07-10 at 11 37 53 am](https://user-images.githubusercontent.com/13905902/28033829-54452372-6564-11e7-84cc-9afdf576252f.png)
Tried to edit the point to have value of 10

![screen shot 2017-07-10 at 11 37 58 am](https://user-images.githubusercontent.com/13905902/28033834-575d5a7a-6564-11e7-80f6-f95d4f034ca7.png)
After I pressed Enter, it reverts back to previous value of 2.

The first table works as intended, but the second tables (the one using array of students), did not. Is there a workaround?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.