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

Silverlight Radgridview header check all checkbox

15 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mahesh
Top achievements
Rank 1
Mahesh asked on 12 Nov 2013, 09:30 PM

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

15 Answers, 1 is accepted

Sort by
0
Mahesh
Top achievements
Rank 1
answered on 13 Nov 2013, 03:25 PM
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);
                }
            }
        }    
0
Accepted
Yoan
Telerik team
answered on 13 Nov 2013, 03:28 PM
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 >>
0
Mahesh
Top achievements
Rank 1
answered on 12 Feb 2014, 10:14 PM
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
0
Yoan
Telerik team
answered on 17 Feb 2014, 04:28 PM
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).

0
Mahesh
Top achievements
Rank 1
answered on 17 Feb 2014, 04:31 PM
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
0
Hristo
Telerik team
answered on 20 Feb 2014, 05:04 PM
Hello Mahesh,

The reason for behavior of the SelectBox column is that, it isn't designed to bind data. The desired behavior can be achieved with a CheckBox column, by modifying the column header. Another benefit of the CheckBox column is that it provides better performance,when the underlying data is of a boolean type

I have attached a sample project demonstrating how create a CheckBox column with a behavior similar to the SelectBox column. Can you please inform me, if this solves your issue?

Regards,
Hristo
Telerik
0
Farkas
Top achievements
Rank 1
answered on 31 Jan 2018, 07:36 PM

Hi,

how can I check the Select All checkbox programaticaly? I would like that checkbox selected by default.

Thanks,

Laszlo

0
Dinko | Tech Support Engineer
Telerik team
answered on 01 Feb 2018, 12:13 PM
Hello Farkas,

What you can do to check the select all CheckBox by default is to subscribe for example to its Loaded event. In the event handler, you can set the IsChecked property to true. For your convenience, I have modified the project from Hristo reply to demonstrate this approach.

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Farkas
Top achievements
Rank 1
answered on 01 Feb 2018, 04:49 PM

Thanks Dinko, your very kind with your fast reply.

What I want to check programaticaly is the filter's Select All checkbox.

So I want all Filters distinct values to be selected when the user opens the filter.

 

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 02 Feb 2018, 02:28 PM
Hello Farkas,

Thank you for elaborating your scenario.

To check the SelectAll CheckBox in the Filter PopUp you can get first all popups in the RadGridView and subscribe to their Opened. You can check this Accessing the filtering popup help article which described how you can get the PopUp in the RadGridView. Then in the Opened event handler, you can get the FilteringControl from the Child property of the PopUp. Using its DataContext (FilteringViewModel) you can set the SelectAll bool property to true.

I have modified the project from my previous reply to demonstrate this approach.

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Farkas
Top achievements
Rank 1
answered on 02 Feb 2018, 06:33 PM

Thanks Dinko

That is what I need, but I got 0 children with type GridViewHeaderCell, however my RadGridView has 5 columns.

do you think I missed something?

 

0
Farkas
Top achievements
Rank 1
answered on 02 Feb 2018, 06:35 PM

Thank you very much Dinko for your example.

That is what I need, but I got 0 items with type GridViewHeaderCell, however my RadGridView has 5 columns.

do you think i missed something?

0
Dinko | Tech Support Engineer
Telerik team
answered on 07 Feb 2018, 08:57 AM
Hi Farkas,

Looking at the attached picture I am not sure what could be the reason behind this. You could get 0 items if you have set the ShowColumnHeaders property of the RadGridView control to False. Can you double check if this property is set and if yes you can set it to True.

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Farkas
Top achievements
Rank 1
answered on 11 Feb 2018, 06:12 PM

Hi Dinko

I checked, the ShowColumnHeaders is True.

Maybe it is something around when I create the columns from code. See my attachment.

Thank you for your effort.

Laszlo

0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Feb 2018, 01:41 PM
Hello Farkas,

Looking at the provided picture it is not clear enough when you are adding the columns to the RadGridView. I have tested your scenario and it is working as expected on my side. I have modified the project from my previous reply. What I have changed is to subscribe to the loaded event of the MainWindow and add the column in the event handler. Can you take a look at this project and let me know how I can reproduce this on my side?

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Mahesh
Top achievements
Rank 1
Yoan
Telerik team
Hristo
Telerik team
Farkas
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or