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

Clear Row/Cell selection in RadGrid

8 Answers 1325 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 2
Daniel asked on 20 Jun 2017, 02:08 AM
How can I clear the row selection in RadGrid? grid.ClearSelection() does not working. I'm using version 2017.1.221.40. Thanks in advance.

8 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Jun 2017, 09:27 AM
Hello Daniel,

You need to set the CurrentRow to null:
private void RadButton2_Click(object sender, EventArgs e)
{
    radGridView1.CurrentRow = null;
}

Please let me know if there is something else I can help you with. 

Regards,
Dimitar
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
Francis
Top achievements
Rank 1
answered on 15 Nov 2019, 03:47 PM
Just as an update. The ClearSelection method is still NOT clearing the selection. Can this be eventually fix or at least mention in the help that it does not clear the actual selection.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Nov 2019, 08:11 AM

Hello, Francis,

According to the provided brief information, it is not clear enough what is the exact scenario that you have on your end and how exactly you use the ClearSelection method? I have noticed that you have opened a support ticket on the same topic. Please see the reply there. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. Thank you for your understanding.

However, I am posting the reply here as well in order the community to benefit from it.  While the grid is in a BeginUpdate/EndUpate block, its updates are suspended. Hence, clearing the selection or setting the CurrentRow may not take effect. These actions have to be performed after calling the EndUpdate method.

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Francis
Top achievements
Rank 1
answered on 18 Nov 2019, 02:00 PM

No this one is different than the open ticket i have. I have a simple button on a new form we are trying to unselect a selected item and clear some textbox. Doing Grid.ClearSelection() do nothing. The row stays highlighted. I have fullrowselect and when selected the whole row is orange.

When i call the Grid.ClearSelection() the cell that was clicked stays Orange and all the other return as "unselected" and it also keep a big orange border around the fullrow. Doing CurrentRow = null clear the visual highlight (selection) properly.

What i suggest is to put CurrentRow = null in the source code of Grid.ClearSelection() so it does actually clear the selection visually as well.Again this is without any begin/end update.

0
Francis
Top achievements
Rank 1
answered on 18 Nov 2019, 02:13 PM

Here i have attached the example of what happen on the first grid i found.

1 - I clicked a grid cell of a grid with fullrowselect.

2 - click a temp button i just made up on the form

private void btnTest1_Click(object sender, EventArgs e) { grdProducts.ClearSelection(); }

3 - Second image show the result of that. The previously "clicked" cell stays selected and a full selection around the complete row still there. The row is still selected despite calling a method call "ClearSelection"

4 - Repeated step 1 where i clicked the same cell and click a second button i just created but with 2 lines of code. ClearSelection and CurrentRow = null.

private void btnTest2_Click(object sender, EventArgs e) { grdProducts.ClearSelection(); grdProducts.CurrentRow = null;  }

The third section of the image show the result that CurrentRow is mandatory to unselect a grid row all the time. Hence why i point out why it should be included automatically so people just don't fall into the trap in the future thinking a method does what it name says. Or maybe create a method intuitively called "ClearVisualSelection" that in the code behind does the "CurrentRow = null". Would have saved me ton of time figuring out the issue that's it.

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Nov 2019, 02:36 PM

Hello, Francis, 

The provided screenshot was greatly appreciated. It helped me to understand better the undesired behavior that you are facing. 

I would like to note that RadGridView may have one or more selected rows/cells and only one current row/cell. Selected and Current state of the row are two different indications for the row and they are purposed to handle different cases: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/selected-rows-and-current-row 

Clearing the selection is expected to clear the selected rows/cells but the current row/cell remains. That is why you see the border around the row and the orange fill color for the current cell. This is expected behavior. 

If you need to clear both, selection and current row, you need to call ClearSelection and set the CurrentRow to null.

Should you have further questions please let me know.

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Francis
Top achievements
Rank 1
answered on 18 Nov 2019, 02:45 PM

So for you guys something highlighted doesn't mean selected. I seriously took less than 2 hours after someone did a release with this piece of code to get over 40 complains from user telling us we did not remove the selection. Sorry but i have to say this is a very bad design. For decades highlighted object meant selected. Users as used to that, it even confused me for couple hours and i have over 30 years experience in programing.

Just saying i fixed the issue with CurrentRow=null and that's okay but you guys might want to do actual user support with real end user and know the reality is for users.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Nov 2019, 07:31 AM

Hello, Francis,

The provided feedback is greatly appreciated. I am really sorry to hear that you were experiencing difficulties with this functionality.

Indeed, there is different style for the current and selected state of the row/cell. This depends on the design for the specific theme that we have, but the current cell is always indicated with a fill color and the current row has a border around it. Setting the CurrentRow to null is expected to achieve the design you need. Feel free to use it. 

If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Francis
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or