Adrian Barnes
Top achievements
Rank 1
Adrian Barnes
asked on 03 Apr 2013, 01:30 PM
I'm apparently missing something here. Trying to change the sort order of a grid that uses GroupByExpressions with no luck.
I started with the following:
Then I tried adding this:
And I tried variations of this, but get either no action or a type mismatch error:
Any suggestions? Thanks!
I started with the following:
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
HeaderText
=
"Order ID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
HeaderText
=
"Customer"
/>
<
telerik:GridGroupByField
FieldName
=
"Total"
HeaderText
=
"Order Total"
FormatString
=
"{0:C}"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
Then I tried adding this:
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"CustLastFirst"
SortOrder
=
"Ascending"
/>
</
SortExpressions
>
And I tried variations of this, but get either no action or a type mismatch error:
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
/>
</
GroupByFields
>
Any suggestions? Thanks!
14 Answers, 1 is accepted
0
Adrian Barnes
Top achievements
Rank 1
answered on 04 Apr 2013, 11:45 PM
Should I just open a support ticket? Thx.
0
Princy
Top achievements
Rank 2
answered on 05 Apr 2013, 06:07 AM
Hi,
You can specify SortOrder in the GroupByFields collection as shown below.
aspx:
Thanks,
Princy
You can specify SortOrder in the GroupByFields collection as shown below.
aspx:
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
SortOrder
=
"Descending"
/>
</
GroupByFields
>
Thanks,
Princy
0
Adrian Barnes
Top achievements
Rank 1
answered on 05 Apr 2013, 12:28 PM
Thanks for the response! Unfortunately, as indicated in my original post, when I add "CustLastFirst" to the GroupByFields, I get an error ("Operator '=' incompatible with operand types 'Object' and 'Int32'").
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
SortOrder
=
"Descending"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
HeaderText
=
"Order ID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
HeaderText
=
"Customer"
/>
<
telerik:GridGroupByField
FieldName
=
"Total"
HeaderText
=
"Order Total"
FormatString
=
"{0:C}"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
0
Hi Adrian,
Could you please elaborate a little bit more on your scenario? What kind of data source you are using? It would be best if you could provide us with your code declaration and the related code behind.
I tried to replicate the issue on my side but to no avail. I prepared a small sample and attached it to this forum post. Please give it a try and let me know how it differs from your real setup.
All the best,
Kostadin
the Telerik team
Could you please elaborate a little bit more on your scenario? What kind of data source you are using? It would be best if you could provide us with your code declaration and the related code behind.
I tried to replicate the issue on my side but to no avail. I prepared a small sample and attached it to this forum post. Please give it a try and let me know how it differs from your real setup.
All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adrian Barnes
Top achievements
Rank 1
answered on 08 Apr 2013, 12:40 PM
Thanks for the response. I will take a look at the code you sent. I am binding to a simple dataset created from a call to stored procedures. I will include my entire grid declaration and the code that binds data to it. I'm actually binding to three grids, but two of them are identical (rdgOrderDetails and rdgExpiredOrderDetails) and each shows a different set of data. Both of those are having the same problem.
If I wrap the Databind() code in a Try..Catch block, the grid renders just fine with all data intact, but without the sorting.
And here is the grid. All of the functions called from the grid are public and expect parameters to be passed as "object." I've looked at those functions and they aren't throwing any errors.
If I wrap the Databind() code in a Try..Catch block, the grid renders just fine with all data intact, but without the sorting.
private void FillSummaryGrid()
{
string sql = "";
string errString = "";
DataSet ds;
sql = "EXEC GetOrderFulfillmentSummaryNew " + cboPickup.SelectedItem.Value;
sql += "; EXEC GetOrderFulfillmentDetailsNotExpired " + cboPickup.SelectedItem.Value;
sql += "; EXEC GetOrderFulfillmentDetailsExpired " + cboPickup.SelectedItem.Value + "; ";
ds = PageData.GetData(sql, ref errString);
rdgOrderDetails.DataSource = ds.Tables[1];
rdgOrderDetails.DataBind();
rdgExpiredOrderDetails.DataSource = ds.Tables[2];
rdgExpiredOrderDetails.DataBind();
}
And here is the grid. All of the functions called from the grid are public and expect parameters to be passed as "object." I've looked at those functions and they aren't throwing any errors.
<
telerik:RadGrid
runat
=
"server"
ID
=
"rdgOrderDetails"
AutoGenerateColumns
=
"false"
Width
=
"1100px"
Skin
=
"WebBlue"
Font-Size
=
"XX-Small"
AllowAutomaticInserts
=
"false"
AllowAutomaticUpdates
=
"false"
ShowFooter
=
"true"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
AllowAutomaticInserts
=
"false"
AllowAutomaticUpdates
=
"false"
CommandItemDisplay
=
"None"
CommandItemSettings-ShowRefreshButton
=
"false"
>
<
Columns
>
<
telerik:GridTemplateColumn
runat
=
"server"
HeaderText
=
"Customer"
>
<
ItemTemplate
>
<%# GetCurrentOrderURL(DataBinder.Eval(Container.DataItem, "OrderID"))%>
<
a
href='CustomerEdit.aspx?cid=<%# DataBinder.Eval(Container.DataItem, "CustomerID")%>' target="_blank"><%# GetCustomerName(DataBinder.Eval(Container.DataItem, "FirstName"), DataBinder.Eval(Container.DataItem, "LastName"))%></
a
>
<%# GetEmail(DataBinder.Eval(Container.DataItem, "Email"))%>
<%# GetPhone(DataBinder.Eval(Container.DataItem, "Phone"))%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
runat
=
"server"
HeaderText="Subscr<br>Status" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
<
ItemTemplate
>
<%# GetSubscriptionStatus(DataBinder.Eval(Container.DataItem, "SubscriptionID"))%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
runat
=
"server"
HeaderText
=
"CustID"
>
<
ItemTemplate
>
<%# GetCustomerID(DataBinder.Eval(Container.DataItem, "CustomerID"))%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
runat
=
"server"
HeaderText
=
"OrderID"
>
<
ItemTemplate
>
<%# GetOrderID(DataBinder.Eval(Container.DataItem, "OrderID"))%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"ItemID"
HeaderText
=
"ItemID"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Quantity"
HeaderText
=
"Qty"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
Aggregate
=
"Sum"
FooterText
=
"Items Ordered : "
FooterStyle-HorizontalAlign
=
"Right"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Price"
DataFormatString
=
"{0:C}"
HeaderText
=
"Price"
></
telerik:GridBoundColumn
>
<
telerik:GridCalculatedColumn
HeaderText
=
"Line Total"
UniqueName
=
"TotalPrice"
DataType
=
"System.Double"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
FooterStyle-HorizontalAlign
=
"Right"
DataFields
=
"DecQuantity, DecWeight, Price"
Expression
=
"({0}*{1})*{2}"
FooterText
=
"Total : "
Aggregate
=
"Sum"
DataFormatString
=
"{0:C}"
/>
</
Columns
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"LastName"
SortOrder
=
"Ascending"
/>
</
SortExpressions
>
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
HeaderText
=
"Order ID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
HeaderText
=
"Customer"
/>
<
telerik:GridGroupByField
FieldName
=
"Total"
HeaderText
=
"Order Total"
FormatString
=
"{0:C}"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
</
MasterTableView
>
</
telerik:RadGrid
>
0
Hello Adrian,
I would suggest you to use advanced data binding instead simple data binding. Please give this approach a try and let me know about the result.
All the best,
Kostadin
the Telerik team
I would suggest you to use advanced data binding instead simple data binding. Please give this approach a try and let me know about the result.
All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adrian Barnes
Top achievements
Rank 1
answered on 15 Apr 2013, 07:18 PM
Thanks for the idea, but that didn't make any difference. The data is coming out of the database in the right order, but somehow the grouping I have going on within the grid is not allowing any of the sorts to work. Below is the latest iteration that doesn't work. If I reverse the order of the <GroupByFields> I get the error message mentioned earlier.
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
/>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
SortOrder
=
"Ascending"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"CustLastFirst"
HeaderText
=
"Customer"
SortOrder
=
"Ascending"
/>
<
telerik:GridGroupByField
FieldName
=
"OrderID"
HeaderText
=
"Order ID"
/>
<
telerik:GridGroupByField
FieldName
=
"Total"
HeaderText
=
"Order Total"
FormatString
=
"{0:C}"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
0
Hello Adrian,
I am afraid without running sample it will be hard to pinpoint the reason for that behavior. Could you please provide us with a small runnable sample or replicate the issue in the sample from my previous post in order to observe the issue locally ?
Kind regards,
Kostadin
the Telerik team
I am afraid without running sample it will be hard to pinpoint the reason for that behavior. Could you please provide us with a small runnable sample or replicate the issue in the sample from my previous post in order to observe the issue locally ?
Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adrian Barnes
Top achievements
Rank 1
answered on 18 Apr 2013, 03:20 PM
After looking at your example and getting nowhere, I decided to start dismantling my grid. Turns out the error is happening because of this column:
Why would a summary/calculated column throw an error when the sorting changes? Once again, the error message is:
<
telerik:GridCalculatedColumn
HeaderText
=
"Line Total"
UniqueName
=
"TotalPrice"
DataType
=
"System.Double"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
FooterStyle-HorizontalAlign
=
"Right"
DataFields
=
"DecQuantity, DecWeight, Price"
Expression
=
"({0}*{1})*{2}"
FooterText
=
"Total : "
Aggregate
=
"Sum"
DataFormatString
=
"{0:C}"
/>
Why would a summary/calculated column throw an error when the sorting changes? Once again, the error message is:
Operator '=' incompatible with operand types 'Object' and 'Int32'
0
Accepted
Hi Adrian,
Can you please check whether setting the EnableLinqExpressions property of the RadGrid instance to false addressed the error you receive? Thus you will force the grid to use the old filter expression comparison and everything should be fine with your Classic implementation.
If you still experience the same behavior, could you please provide us with your code declaration and the related code behind in order to investigate the issue further.
Kind regards,
Kostadin
the Telerik team
Can you please check whether setting the EnableLinqExpressions property of the RadGrid instance to false addressed the error you receive? Thus you will force the grid to use the old filter expression comparison and everything should be fine with your Classic implementation.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
EnableLinqExpressions
=
"false"
>
If you still experience the same behavior, could you please provide us with your code declaration and the related code behind in order to investigate the issue further.
Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adrian Barnes
Top achievements
Rank 1
answered on 23 Apr 2013, 06:11 PM
Kostadin,
Thanks! That fixed the problem. What do you mean by "the old filter comparison method?" I put together this particular grid using examples on Telerik's site (for the calculated columns, grouping, and such). Did I do something the wrong way? I do not use LINQ on purpose. Is that it?
Thanks!
Adrian
Thanks! That fixed the problem. What do you mean by "the old filter comparison method?" I put together this particular grid using examples on Telerik's site (for the calculated columns, grouping, and such). Did I do something the wrong way? I do not use LINQ on purpose. Is that it?
Thanks!
Adrian
0
Hello Adrian,
The differences is that when EnableLinqExpressions is enabled the ongoing operations are using linq, otherwise they are using .NET 2.0 approach.
Greetings,
Kostadin
the Telerik team
The differences is that when EnableLinqExpressions is enabled the ongoing operations are using linq, otherwise they are using .NET 2.0 approach.
Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Erik
Top achievements
Rank 1
answered on 26 Sep 2016, 11:14 PM
I am running into this issue as well. Do you have any plans to fix this bug? Looks like it's been about 2 years
0
Hi Erik,
I tried to replicate the issue on my end but to no avail. Could you please check out the attached sample and let me know how it differs from your real setup? I would appreciate if you can share more details about the grid configuration and the dataosource which is using.
Regards,
Kostadin
Telerik by Progress
I tried to replicate the issue on my end but to no avail. Could you please check out the attached sample and let me know how it differs from your real setup? I would appreciate if you can share more details about the grid configuration and the dataosource which is using.
Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.