Radgrid Group Footer Dynamic calculation

4 posts, 0 answers
  1. cheah
    cheah avatar
    4 posts
    Member since:
    Oct 2014

    Posted 15 Apr 2015 Link to this post

    Hi all,

    Currently I am facing a problem regarding Radgrid Group Footer Dynamic calculation.

    I have a radgrid that have some GridTemplateColumns that allow me to key in some value

    Example

     <telerik:GridTemplateColumn UniqueName="Quantity" HeaderText="Quantity"  DataField="Quantity" Aggregate="Sum" >
                                            
                                                <ItemTemplate>
                                                     <asp:TextBox ID="lbl_Quantity" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity" , "{0:0.00}") %>'
                                                        Width="40px" runat="server" autopostback="true" onTextChanged="calQuantity"></asp:TextBox>
                                                    <br />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>

     

     <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="Grp"></telerik:GridGroupByField>
                            </GroupByFields>
                            <SelectFields>
                                <telerik:GridGroupByField FieldName="Grp" HeaderText="Week"></telerik:GridGroupByField>
                            </SelectFields>
                        </telerik:GridGroupByExpression>

     

    Group Footer displayed correctly when the grid load. However, what I was trying to achieve is when I change the value of the quantity it will auto recalculate the group footer. I tried to achieve it using onTextChanged="calQuantity" but not success.

    Do you all have any idea on this? 

    Thank you.

     

     

     

     

  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 20 Apr 2015 Link to this post

    Hello Cheah,

    Generally, you will need to commit this value to the database and rebind the grid to update the calculated Aggragates. But I guess you will need an instant updating approach, similar to this scenario:
    http://www.telerik.com/help/aspnet-ajax/grid-totals-with-numerictextbox.html

    I am also sending a sample RadGrid web site sample to demonstrate a basic implementation of findElement and findControl methods which you can use to create a solution on client-side.

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cheah
    cheah avatar
    4 posts
    Member since:
    Oct 2014

    Posted 20 Apr 2015 Link to this post

    Hi Eyup,

     

    Really thanks for your suggestion. 

    However I think that is a bit different from what I need to achieve. 

    Based on the attached screenshot, there are 2 types of footer(circled one) that need to be calculated dynamically.

    Is there anyway to do it in javascript or server side? 

    Thanks a lot.

     

    Regards,

    Cheah

     

  5. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 23 Apr 2015 Link to this post

    Hi Cheah,

    You can use Aggregates provided by RadGrid to achieve this requirement:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/grouping/group-footers/defaultcs.aspx

    If you want to implement a custom script solution, you can try to use findControl and findElement methods as suggested in my previous post. Here are other methods which may prove helpful:
    var tableView = grid.get_masterTableView();
    var footer = $(tableView.get_element()).find(".rgFooter")[0];
    var colCell = tableView._getCellByFooterColumnUniqueNameFromTableRowElement(footer, "ColUniqueName");
    $(colCell).text("Some New Text");

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top