Trigger PropertyChanged or CellEndEdit on CheckBoxColumn

4 posts, 0 answers
  1. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 18 Nov 2014 Link to this post

    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
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 19 Nov 2014 Link to this post

    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.

     
  3. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 19 Nov 2014 in reply to Boris Link to this post

    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
  4. Boris
    Admin
    Boris avatar
    276 posts

    Posted 21 Nov 2014 Link to this post

    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.

     
Back to Top