DropDownList State for Grid

2 posts, 0 answers
  1. Sourav
    Sourav avatar
    12 posts
    Member since:
    Jul 2020

    Posted 07 Aug 2020 Link to this post

    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}
                />
            );
        }

  2. Sourav
    Sourav avatar
    12 posts
    Member since:
    Jul 2020

    Posted 07 Aug 2020 Link to this post

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

    Thank you for the example.

Back to Top