Disable row selection

5 posts, 1 answers
  1. Jurjen Ladenius
    Jurjen Ladenius avatar
    25 posts
    Member since:
    Jan 2006

    Posted 02 Feb 2011 Link to this post

    Hi,

    I wish to disable the row selection checkbox for rows based on content criteria.
    I'm binding with an observable collection of objects that implement INotifyPropertyChanged.
    Let's say that each object has a CanSelect boolean property.
    What is the best way to disable the checkbox?

    I've tried:

    private

     

     

    void myGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) {
        var theObject = e.DataElement as TheObject;
        if (theObject != null)
        {
            e.Row.Cells[0].IsEnabled = theObject.CanSelect;
        }
    }

    This doesn't work, since I can select disabled checkboxes, because I can select the row by clicking it.

    Kind regards,

    Jurjen

     

     

     

     

     

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts
    Member since:
    Jul 2012

    Posted 02 Feb 2011 Link to this post

    Hello Jurjen Ladenius,

    Why not setting the whole row to be disabled?

    e.Row.IsEnabled = false;



    Regards,
    Veselin Vasilev
    the Telerik team

    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>

  3. DevCraft Release
  4. Jurjen Ladenius
    Jurjen Ladenius avatar
    25 posts
    Member since:
    Jan 2006

    Posted 02 Feb 2011 Link to this post

    That works quite well, but this has visual effects and all child controls get disabled, even when they've been explicitly enabled in the same routine.
    I have some RadButtons in the grid that need to be enabled (opens a detail window)... Any suggestion?

  5. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts
    Member since:
    Jul 2012

    Posted 02 Feb 2011 Link to this post

    Hello Jurjen Ladenius,

    As an alternative you can subscribe to the SelectionChanging event of RadGridView and check the CanSelect property there. Cancel the event if the row should not be selected.

    Best wishes,
    Veselin Vasilev
    the Telerik team

    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>

  6. Jurjen Ladenius
    Jurjen Ladenius avatar
    25 posts
    Member since:
    Jan 2006

    Posted 02 Feb 2011 Link to this post

    This gives me exactly the wanted functionality. Thanks!

Back to Top
DevCraft Release