longbridgeapp / gpui-component

UI components write in GPUI.
Apache License 2.0
150 stars 20 forks source link

table: how can I mutate the state in a cell? #319

Closed zhaopuming closed 6 days ago

zhaopuming commented 1 week ago

For example, I'd like to render a checkbox for a column with boolean value, how can I update the state of table data?

Currently, render_td has a immutable reference to self, so there's no way to mutate the data related to current td.

    fn render_td(
        &self,
        row_ix: usize,
        col_ix: usize,
        _cx: &mut ViewContext<Table<Self>>,
    ) 
huacnlee commented 1 week ago

You must give me more information about what you want to do.

Do you want click checkbox to toggle state? If true, you can checkout something like cx.listener that I was wrote in example.

zhaopuming commented 6 days ago

Thanks, I found the cx.listener example and it works :-)