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

Issue with sorting SPDataSource from RadGrid

6 Answers 89 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
rh
Top achievements
Rank 1
rh asked on 02 Jun 2009, 11:36 PM
When I sort a RadGrid that is bound to an SPDataSource I get the following error:

One or more field types are not installed properly. Go to the list settings page to delete these fields.


When I look at the SharePoint logs I notice that the select command contains an order by clause that is presumably somehow being added by RadGrid because it is nowhere in my code and this is the collumn that I clicked on.

<OrderBy><FieldRef Name="Process2 ASC" Ascending="TRUE"></FieldRef></OrderBy> 

Notice that the FieldRef in the order by clause has a name of "Process2 ASC". It is my assumption that the "ASC" in the field name is causing the issue. How do I get it to not include the ASC in the field name in the order by?

I tried updating the SortExpression in the SortCommand event of the grid but SortExpression is a read only property. I'm not too sure what else to do.

protected

 

void _grid_SortCommand(object source, GridSortCommandEventArgs e)

 

{

e.SortExpression = e.SortExpression.Replace(

" ASC", String.Empty);

 

e.SortExpression = e.SortExpression.Replace(

" DESC", String.Empty);

 

}

6 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 03 Jun 2009, 01:36 PM
Hello rh,

Can you please check whether the same issue appears when you replace temporary the RadGrid instance with regular MS GridView? Additionally, note that you can control the sorting modes manually intercepting the SortCommand event of the grid and canceling the default sort operation as illustrated in this topic from the documentation. This should help you apply the sort criteria and avoid the exception.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
rh
Top achievements
Rank 1
answered on 03 Jun 2009, 05:24 PM
I've looked at the SortCommand event but fail to see how it will help for a number of reasons:

  1. The GridSortExpression needs a field name but the GridSortCommandEventArgs doesn't provide the field name.
  2. All you can really do with the GridSortExpression is set the FieldName and the SortOrder. I fail to see how this is going to prevent the ASC keyword from being put in the FieldRef name.

The ASP.NET GridView does not generate the error below when sorting. That's the good news. The bad news is that it doesn't sort. It just refreshes the page without doing anything.

0
Sebastian
Telerik team
answered on 04 Jun 2009, 12:11 PM
Hello rh,

You can traverse the SortExpressions collection of the respective GridTableView as illustrates in the code example from the documentation topic and modify the FieldName passed from the FieldRef (Process2 ASC) to remove the ASC part. Thus you should be able to avoid the error/unexpected result you saw in the same scenario with the MS GridView.

Additionally, you can specify the sort order manually if you would like to. Keep in mind that you need to cancel the default action first and rebind the grid explicitly at the end of the SortCommand handler.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Elad
Top achievements
Rank 1
answered on 19 Jul 2009, 02:01 PM
Hi,
I am having the exact same issue.
I have tried what you suggested, but it doesn't work.
To make the problem more clear I run the following test:

In the Sort Event handler, I set the FieldName property of the sort expression to a constant string - "MyTest". This is not one of my fields, it's just a string that i can recognize later.
Then, I run the app, get the same error, and in the log files I see that the query was:
<OrderBy><FieldRef Name="MyTest ASC" Ascending="True"></FieldRef></OrderBy>
So radGrid appends the sort expression to the field name even if I manually set the field name!

Any suggestions?

Thanks,
Elad.
0
rh
Top achievements
Rank 1
answered on 19 Jul 2009, 02:33 PM
I agree. I wish Telerik would take the time to recreate the problem and try to implement their suggested solution themselves. If they find that it works that would be great and they can post the solution in more detail. However, I think they may find that it doesn't work.

I gave up trying to use the RadGrid in SharePoint because of this issue and went back to using the SPGridView.
0
Sebastian
Telerik team
answered on 21 Jul 2009, 03:55 PM
Hello guys,

In order to workaround the issue with the way SPDataSource handles sorting, you will need to handle the sorting manually as explained previously in my reply or as shown in this help article.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Sharepoint Integration
Asked by
rh
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
rh
Top achievements
Rank 1
Elad
Top achievements
Rank 1
Share this question
or