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

How to sort by arithmetic result of several fields in client-side grid?

0 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 01 Mar 2012, 10:15 PM
Hello,

I am using client-side binding grid, so all my columns are gridtemplatecolumn type and filled from web-service.
One of the columns is a result of some calculation.

<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="Start day throughput" SortExpression="START_DAY_DATA.IO_PER_SECOND">
    <itemtemplate>
        <asp:Label ID="StartPerSecond" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="End day throughput" SortExpression="END_DAY_DATA.IO_PER_SECOND">
    <itemtemplate>
        <asp:Label ID="EndPerSecond" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen ra' ItemStyle-CssClass='ra'
    HeaderText="Throughput growth">
    <itemtemplate>
        <asp:Label ID="PerSecondDelta" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>


When I put SortExpression="(END_DAY_DATA.IO_PER_SECOND - START_DAY_DATA.IO_PER_SECOND)" into third column - I am getting the exception when trying to sort by this column.

I can't believe I can't solve this problem in a more elegant way than writing something like:
SELECT
  END_DAY_DATA.IO_PER_SECOND,
  START_DAY_DATA.IO_PER_SECOND
  END_DAY_DATA.IO_PER_SECOND - START_DAY_DATA.IO_PER_SECOND
........
and putting SortExpression="3" for third column! :(

UPDATE: Lack of time for experiments: so, I've used the last approach: SortExpression="3" :)

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Share this question
or