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

Radgrid Group Footer Dynamic calculation

3 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cheah
Top achievements
Rank 1
cheah asked on 15 Apr 2015, 07:45 AM

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.

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Apr 2015, 06:29 AM
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.

 
0
cheah
Top achievements
Rank 1
answered on 21 Apr 2015, 01:19 AM

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

 

0
Eyup
Telerik team
answered on 23 Apr 2015, 08:07 AM
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.

 
Tags
Grid
Asked by
cheah
Top achievements
Rank 1
Answers by
Eyup
Telerik team
cheah
Top achievements
Rank 1
Share this question
or