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

Set RadGridView Column sort order

4 Answers 144 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 20 May 2014, 06:12 PM
Hi,

I'm testing a Silverlight app and I'm trying to validate the correct data sort on a RadGridView. Is there a way I can interact with the column header to set to sort order I want (ex: "Ascending" or "Descending").

Right now I have a coded step to click on the column header and than I validate the ascending sort and then I click again on the header and I validate the descending sort. But what I'm looking for is a way to set the column sort without having to click on it.

Something like: RadGridView.Header[0].Sort(Ascending);

Using XAML Spy I'm able to see a property "SortingState" on the GridViewHeaderCell element that has the value sort (ex: "Ascending") but I'm not able to reach that property on my code. I don't even know if is possible to use such property to set the desired sort of the column

What are my possibilities?

Best Regards,
Luis

4 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 23 May 2014, 02:12 PM
Hi Luis,

I want to start at a high level talking about automatation in general, what you should and should not automate. 

Test Automation of any application needs to focus on testing the business logic of the application e.g. can I add 2+ items to my cart, are the calculations correct including shipping.

You want to avoid developing automated tests for things that are very hard to automate and provide little value e.g. is the color of this error text red, or something in which your team has no control over.

Testing the sort order of data presented in a third party grid control falls into one of those things you have no control over. The code built into the RadGridview control does all of the sorting for you, not any of the code your developer writes. If it happens to be broken you have to show us (the Telerik RadControl team) how it's broken. There's nothing your web developer can do to fix it himself.

Even the column header/button that you click on to change the sort order is drawn by the RadGridViewcontrol and is wired directly to that control.

Thus our official recommendation is to manually test the sort order once then forget about it. If your team upgrades the version of the RadControls being used. Then you'll want to test it once again manually, and again you can forget about it after that. It's either going to work, or not work. There's nothing your web developer can do to cause sorting to stop working. Again if it's not working your team cannot fix it... only the maker of the control (Telerik) can fix it for you. Your time would be much better spent developing automated tests that test the code your web developers have written instead of the code contained in third party controls such as the Telerik RadGridView control.

Now, having said all that, if you still want to proceed down the path of developing an automated test to validate the sort order I can still offer you a few pointers.
  1. Being you're dealing with a Silverlight control, clicking on it is the only way to change the sort order. The property you have referenced cannot be set directly. There is a very small handful of Silverlight control properties we set directly, unfortunately that one is not included in the set (and FYI, we have to write wrapper code for every property we want to be able to set in order to jump the high wall between the Test Studio process and the Silverlight run-time engine process i.e. it's somewhat expensive to create a settable property using a wrapper which is why we don't try to do all of them).
  2. Because the order of the data presented in the Silverlight Visual Tree is not necessarily the order it's displayed in the UI you have to be extra careful when scanning the data to verify the sort order. We have written this code sample to show what it takes. Because of the work involved in validating the sort order of any Silverlight data, this is another argument saying it may not be worth the effort required to develop it plus maintain it if the validation stops working for any reason.


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Luis
Top achievements
Rank 1
answered on 23 May 2014, 03:33 PM
Hi Cody,

First of all thank you for your tips.

The application I'm testing uses DataGrids and RadGridview and we first start by implementing tests to validate sort on DataGrids and then we have extended to RadGridview as well.

Actually, after the implementation of the a validate sort script for one RadGridview we discover a sort bug (don't know if has to do with the control itself or the way the data is bind to the control).

From what I understand there is no way to interact directly with the column sort besides using clicks.

Despite being costly to implement do you have this feature plan on your roadmap? 

Is there a way just to know the sort being applied to a column?

BR,
Luis




0
Cody
Telerik team
answered on 27 May 2014, 09:42 PM
Hi Luis,

I don't know if this feature is currently on our planned road map or not. I've added a feature request to make sure our product manager will consider it.

I've asked my development team for ideas how to test what the currently set sorting order is. I should have an answer for you tomorrow on this.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Cody
Telerik team
answered on 29 May 2014, 01:31 PM
Hi Luis,

After going back and forth a couple times with development we've reached the conclusion that currently there is no way to simply detect what the current sort order is for a given column. I am hoping we will be able to expose this property so that it can be easily verified in a Test Studio test.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Luis
Top achievements
Rank 1
Answers by
Cody
Telerik team
Luis
Top achievements
Rank 1
Share this question
or