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

Trigger PropertyChanged or CellEndEdit on CheckBoxColumn

3 Answers 589 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 18 Nov 2014, 09:55 AM
Hi,

I need to have a couple of checkboxes in a grid that would trigger property changed as soon as they're checked. I've tried binding with UpdateSourceTrigger as PropertyChanged however that only triggers when I click on another cell.

Another possible solution is to trigger CellEditEnded as soon as the value is changed (i.e. checkbox is checked or unchecked).

Thanks,
Daryl

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 19 Nov 2014, 04:39 PM
Hello Daryl,

A possible way to achieve your goal is to implement the INotifyPropertyChanged interface in your ViewModel. For a more practical example you can check our BoundSelectColumn sdk demo. The example demonstrates both the GridViewSelectColumn and GridViewCheckBoxColumnAlthough GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples by developing our SDK Samples Browser.

I hope this helps.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alan
Top achievements
Rank 1
answered on 19 Nov 2014, 05:51 PM
Hi Boris,

Thank you for your reply.

Unfortunately my aim is not to have a select checkbox column but to have multiple columns that can be checked and it would update the model immediately. The model already implements INotifyPropertyChanged but right now we need to first get into edit mode, then check the checkbox and move out of the checkbox for it to go through the cell edit ended event.

Regards,
Daryl
0
Boris
Telerik team
answered on 21 Nov 2014, 10:01 AM
Hello Daryl,

A possible way to update your ViewModel immediately is to define a CheckBox in the CellTemplate of a GridViewDataColum and set the UpdateSourceTrigger property in the binding to PropertyChanged.

<telerik:GridViewDataColumn>
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

For more information about how to set CellTemplate, you can check the Setting CellTemplate and CellEditTemplate documentation article.

Please note that by doing so you will not trigger the CellEditEnded event. 


Let me know how it works for you.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Alan
Top achievements
Rank 1
Answers by
Boris
Telerik team
Alan
Top achievements
Rank 1
Share this question
or