Grouping a gridcolumn on a function-based value
1 Answer 18 Views
Antoine
Top achievements
Rank 1
Antoine asked on 13 Jul 2021, 09:37 AM

Hi, 

Currently working with a RadGrid on ASP.Net AJAX, I'm using a GridTemplateColumn to display some informations. Here's the code :

<telerik:GridTemplateColumn AutoPostBackOnFilter="true" UniqueName="UniqueName1" HeaderText="Header text" HeaderStyle-HorizontalAlign="Center" FilterControlWidth="80%" >
   <ItemTemplate>
      <asp:Literal ID="Literal1" Text='<%# MyFunction(DataBinder.Eval(Container.DataItem, "myField").ToString())%>' runat="server" />
   </ItemTemplate>
</telerik:GridTemplateColumn>

The problem is : I've got a code "myField" wich is returned from the datasource. Then I load a full string from this code with the function "MyFunction".

What I would like to do is to be able to group the column on the resulting string of the function, not on the code.

Hope you can help.

1 Answer, 1 is accepted

Sort by
1
Accepted
Doncho
Telerik team
answered on 16 Jul 2021, 07:13 AM

Hi Antoine,

I am afraid grouping by custom-generated string goes beyond the capabilities of the control. The grouping functionality of RadGrid works based on the DataSource fields that are bound to the control, refer to GridGroupByExpression object.

The desired behavior could be possible if you create an additional field in the data source that contains the already manipulated value of another field and set it as FieldName of the desired Group expression.

Kind regards,
Doncho
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Antoine
Top achievements
Rank 1
commented on 16 Jul 2021, 07:30 AM

Thanks for your answer Doncho.
This is what I was doing but I do not want to add a field in my Business Class, so I've created a new class in my Presentation Layer that fits perfectly to my needs.

Antoine.
Tags
Grid
Asked by
Antoine
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or