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

1 posts, 0 answers
  1. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 01 Mar 2012 Link to this post

    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" :)
Back to Top