Silverlight Radgridview header check all checkbox

6 posts, 1 answers
  1. Mahesh
    Mahesh avatar
    4 posts
    Member since:
    Jan 2013

    Posted 12 Nov 2013 Link to this post

    I am trying to implement 'check all' checkbox at header Silverlight RadGridView 

    Requirement:

                    When user checks the header checkbox of the RadGridView then all the check box of rows should get selected. However when a particular property or business specific of data, is false then that particular row checkbox shouldn't get checked.

    Current implementation:
    I have subclassed GridViewSelectColumn hoping that when user checks header checkbox telerik radgridview control only selects all enabled checkbox, but problem is it is selecting disabled checkbox as well.

    Please advise.

    Thanks,
    Mahesh

     public class MyGridViewSelectColumn : GridViewSelectColumn
        {

            public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
            {
                var element = base.CreateCellElement(cell, dataItem);

                var job = (JobDAO)dataItem;

                var checkBox = element as CheckBox;
                if (checkBox != null && job != null)
                {
                    checkBox.SetBinding(CheckBox.IsEnabledProperty, new Binding { Source = job.IsSelectable, Mode = BindingMode.OneWay  });                           
                    CheckBox.
                }

                return element;
            }

            protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args)
            {
                base.OnPropertyChanged(args);
            }
        }


    Thanks,
    Mahesh

  2. Mahesh
    Mahesh avatar
    4 posts
    Member since:
    Jan 2013

    Posted 13 Nov 2013 Link to this post

    I am able to handle this. Following is the code snippet.


     private void gvJobs_SelectionChanged(object sender, SelectionChangeEventArgs e)
            {
                foreach (var item in e.AddedItems)
                {
                    if (!((model)item).IsSelectable)
                    {
                        this.radgrid.SelectedItems.Remove(item);
                    }
                }
            }    
  3. DevCraft banner
  4. Answer
    Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 13 Nov 2013 Link to this post

    Hello Mahesh,

    Thank you for the update. I am glad to hear that this solution works for you.

    Please if you face any further difficulties do not hesitate to contact us.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Mahesh
    Mahesh avatar
    4 posts
    Member since:
    Jan 2013

    Posted 12 Feb 2014 in reply to Yoan Link to this post

    Hello:

    I need help. Your solution works for select all or selection. Now I need to removed the selected rows when user clicks on Unselect all checkbox (header checkbox).

    Thanks,
    Mahesh
  6. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 17 Feb 2014 Link to this post

    Hello Mahesh,

    I am sorry, but I am not sure that I can understand your scenario. May I ask you to elaborate a little bit more details on the exact use case you have? Do you want to "hide" the rows?

    Looking forward to hearing from you!


    Regards,
    Yoan
    Telerik

    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

  7. Mahesh
    Mahesh avatar
    4 posts
    Member since:
    Jan 2013

    Posted 17 Feb 2014 in reply to Yoan Link to this post

    Yoan,

    The solution you guys gave me its working fine when user clicks on select all checkbox. But when user clicks again on select all <gridviewselectcolumn> check box I need to de select the selected rows.

    Thanks,
    Mahesh
Back to Top
DevCraft banner