Reading updated Data Grid text box value

I have a simple DataGrid with columns where the first column is a text box field:

User edits a value in the text box, e.g changes name from “Alice” to “John”

How can I “read” the updated field value? A simple print button

def button_1_click(self, **event_args):
    """This method is called when the button is clicked"""
    print(self.repeating_panel_1.items)
    
    pass

still prints the original name “Alice”, instead of the updated text box value (instead of “John”):
[{'column_1': 'Alice', 'column_2': '1 Road Street''}, {'column_1': 'Bob', 'column_2': '2 City Town'}]

If your data grid holds a list of dictionaries (not a list of data table rows), then you can use data binding on your text box to change the underlying dictionary, e.g. bind the text property to self.item['column_1']. Then as the text box changes the underlying dictionary will change.

If your data grid holds data table rows it becomes more complicated, since you don’t typically want the client to be able to directly update those.

1 Like