This is a migrated thread and some comments may be shown as answers.

DropDownList State for Grid

1 Answer 21 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sourav
Top achievements
Rank 1
Sourav asked on 07 Aug 2020, 08:51 PM

Hi,

 

I am building a grid with DropDownList and Editable field. I am struggling to change the value of the DropDownList by changing state. All the DropDownLists have same set of values appearing in each row of the Grid.

 

I have tagged Id field of DropDownList with the rendered Id of the master data. Hence, after 'onChange' event fires, I am able to track the Id and lookup for the index of master data by the Id and then update the selected DropDownList value in it. I am then setting the state with the changed data which shows the selected value in the DropDownList.

Is there an easy way to handle DropDownList state change? How could I assign state for each row of a grid?

 

 

return (
            <Grid
                data={state.data}
                onItemChange={itemChange}
                editField="inEdit"
            >
                <Column field="Name" title="Name" sortable={false} />
                <Column field="Code" title="Code" cell={CodeList}/>
                <Column field="Notes" title="Notes" />
            </Grid>

 

 

 

 

const CodeList = (props) =>
    {
        return(
               <DropDownList 
                data={CodeNames} 
                value={props.dataItem.Code}
                onChange={handleChange}
                id={props.dataItem.Id}
            />
        );
    }

1 Answer, 1 is accepted

Sort by
0
Sourav
Top achievements
Rank 1
answered on 08 Aug 2020, 04:22 AM

I found answer for the question in the example - https://stackblitz.com/edit/react-grid-cells?file=editorCell.js

Thank you for the example.

Tags
General Discussions
Asked by
Sourav
Top achievements
Rank 1
Answers by
Sourav
Top achievements
Rank 1
Share this question
or