Hi, I am developing a Webpage where I have RadGrid for multiple Products Entry.
It has Product Name, Quantity, UnitPrice and Total Price Fields.
User can keep adding products, quantity, UnitPrice and also can change any of the existing quantity, unitprice.
Total Price should always be calculated automatically as Quantity * Unit Price, upon any change on Quantity TextBox or UnitPrice Textbox.
I also have one more Server Label where I display Total of Total Price.
Now what I am looking for is a JavaScript Function to calculate all the Rows Quantity * its Unit Price and display it to its Total Price. And total of the Total price ( of all the rows ) should be displayed to the server side Label.
Can someone please help me for this JavaScript function? I think I can attach it to the ItemTemplate's Controls while binding Grid so that if there is any change in that Control Values, It should always calculate Total of All the Rows of Grid.
Here is my Grid: In the given code,
#############################################################
| <telerik:RadGrid ID="RadGridDetails" runat="server" AllowPaging="false" |
| AllowSorting="true" AutoGenerateColumns="False" GridLines="Both" |
| OnNeedDataSource="RadGridDetails_needdatasource" Skin="Default" |
| OnItemCreated="RadGridDetails_ItemCreated" |
| OnItemDataBound="RadGridDetails_ItemDataBound" |
| ShowFooter="true" |
| > |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <ClientSettings EnableRowHoverStyle="true"> |
| </ClientSettings> |
| <MasterTableView ShowHeadersWhenNoRecords="true"> |
| <Columns> |
| <telerik:GridTemplateColumn > |
| <ItemTemplate> |
| <asp:Button runat="server" ID="btnDeleteProduct" text="Delete" |
| CssClass="ButtonCSS" |
| ToolTip="Click here to delete this product" |
| CausesValidation="true" |
| OnClientClick="javascript:return confirm('Are you sure you want to delete this Product Information? ');" |
| onclick="btnDeleteProduct_Click" |
| CommandArgument='<%# |
| Eval ( "RequestInfoProductDetailID").ToString() |
| + ";" + |
| Eval ( "Row_Number").ToString() |
| %>' |
| /> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:Button runat="server" ID="btnAddProduct" text="Add New Product" |
| CssClass="ButtonCSS" |
| ToolTip="Click here to add this new product to the list" |
| CausesValidation="true" onclick="btnAddProduct_Click" |
| /> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Quantity" UniqueName="Quantity"> |
| <ItemTemplate> |
| <asp:TextBox ID="txtQty" Runat="server" MaxLength="7" |
| Text='<%# Bind("Quantity") %>' |
| ToolTip="Enter quantity" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvQty" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid quantity" |
| ControlToValidate="txtQty" Operator="DataTypeCheck" |
| Type="Integer" ></asp:CompareValidator> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:TextBox ID="txtEnterQty" Runat="server" MaxLength="7" |
| ToolTip="Enter quantity" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvEnterQty" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid quantity" |
| ControlToValidate="txtEnterQty" Operator="DataTypeCheck" |
| Type="Integer" ></asp:CompareValidator> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Product Name" SortExpression="ProductName" |
| UniqueName="ProductName"> |
| <ItemTemplate> |
| <asp:TextBox ID="txtProductName" Runat="server" MaxLength="50" |
| Text='<%# Bind("ProductName") %>' |
| ToolTip="Enter ProductName" |
| ></asp:TextBox> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:TextBox ID="txtEnterProductName" Runat="server" MaxLength="50" |
| ToolTip="Enter ProductName" |
| ></asp:TextBox> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Unit Cost" SortExpression="UnitCost" UniqueName="UnitCost"> |
| <ItemTemplate> |
| <asp:TextBox ID="txtUnitCost" Runat="server" MaxLength="10" |
| Text='<%# Bind("UnitCost") %>' |
| ToolTip="Enter Unit Cost" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvUnitCost" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid amount" |
| ControlToValidate="txtUnitCost" Operator="DataTypeCheck" |
| Type="Double" ></asp:CompareValidator> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:TextBox ID="txtEnterUnitCost" Runat="server" MaxLength="10" |
| ToolTip="Enter Unit Cost" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvEnterUnitCost" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid amount" |
| ControlToValidate="txtEnterUnitCost" Operator="DataTypeCheck" |
| Type="Double" ></asp:CompareValidator> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Total Cost" |
| SortExpression="TotalCost" |
| UniqueName="TotalCost"> |
| <ItemTemplate> |
| <asp:Label runat="server" ID="lblTotalCost" Text='<%# Bind("TotalCost") %>' ></asp:Label> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:Label runat="server" ID="lblFooterTotalCost" ></asp:Label> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| <EditFormSettings> |
| <PopUpSettings ScrollBars="None" /> |
| </EditFormSettings> |
| <ExpandCollapseColumn Resizable="False" Visible="False"> |
| <HeaderStyle /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:Label ID="lblSubTotal" runat="server" ></asp:Label> |
#############################################################
| function Huh(sender, e) { |
| // Find the scheduler |
| var rsScheduler = $find('ctl00_ContentPlaceHolder1_rsScheduler'); |
| // Get the variable for the active lease |
| var nActiveLeaseID = document.getElementById("ctl00_ContentPlaceHolder1_m_nActiveLease"); |
| // Get the appointments from the schduler |
| var Appointments = rsScheduler.get_appointments(); |
| // Get our appointment |
| var MyAppt = Appointments.findByID(nActiveLeaseID.value); |
| //Edit the appointment |
| rsScheduler.editAppointment(MyAppt); |
| } |
<telerik:RadMenuItem IsSeparator="true" Text="|" />
please help and let me know what I need to do to make the divider appear. thanks.

Hi, I am using Tekerik:RadGrid and I have columns as Quantity, UnitPrice and TotalPrice.
I provide Textboxes to enter Quantity and Unit Price and upon these entry, immediately TotalPrice Label should be calculated as quantity * Unit Price.
Now, I also display the total of all the Total Price in a different Label control.
I want to know how can I write a Javascript function to attach it on "onkeyup" event of Quantity and Unit Price textboxes so that whenever there is any change in any quantity or any unit price, it calculates every thing and fills out total also.
Just for information, here is my RadGrid Control:
#####################################
| <telerik:RadGrid ID="RadGridDetails" runat="server" AllowPaging="false" |
| AllowSorting="true" AutoGenerateColumns="False" GridLines="Both" |
| OnNeedDataSource="RadGridDetails_needdatasource" Skin="Default" |
| OnItemDataBound="RadGridDetails_ItemDataBound" |
| ShowFooter="true" |
| > |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <ClientSettings EnableRowHoverStyle="true" > |
| </ClientSettings> |
| <MasterTableView ShowHeadersWhenNoRecords="true"> |
| <Columns> |
| <telerik:GridTemplateColumn HeaderText="Row_Number" |
| SortExpression="Row_Number" UniqueName="Row_Number"> |
| <ItemTemplate> |
| <asp:Label ID="lblRow_Number" runat="server" |
| Text='<%# Bind("Row_Number")%>'></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn > |
| <ItemTemplate> |
| <asp:Button runat="server" ID="btnDeleteProduct" text="Delete" |
| CssClass="ButtonCSS" |
| ToolTip="Click here to delete this product" |
| CausesValidation="true" |
| OnClientClick="javascript:return confirm('Are you sure you want to delete this Product Information? ');" |
| onclick="btnDeleteProduct_Click" |
| CommandArgument='<%# |
| Eval ( "RequestInfoProductDetailID").ToString() |
| + ";" + |
| Eval ( "Row_Number").ToString() |
| %>' |
| /> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:Button runat="server" ID="btnAddProduct" text="Add New Product" |
| CssClass="ButtonCSS" |
| ToolTip="Click here to add this new product to the list" |
| CausesValidation="true" onclick="btnAddProduct_Click" |
| /> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Quantity" UniqueName="Quantity"> |
| <ItemTemplate> |
| <asp:TextBox ID="txtQty" Runat="server" MaxLength="7" |
| Text='<%# Bind("Quantity") %>' |
| onkeyup='isNumber(this)' |
| ToolTip="Enter quantity" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvQty" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid quantity" |
| ControlToValidate="txtQty" Operator="DataTypeCheck" |
| Type="Integer" ></asp:CompareValidator> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:TextBox ID="txtEnterQty" Runat="server" MaxLength="7" |
| ToolTip="Enter quantity" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvEnterQty" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid quantity" |
| ControlToValidate="txtEnterQty" Operator="DataTypeCheck" |
| Type="Integer" ></asp:CompareValidator> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Unit Cost" SortExpression="UnitCost" UniqueName="UnitCost"> |
| <ItemTemplate> |
| <asp:TextBox ID="txtUnitCost" Runat="server" MaxLength="10" |
| Text='<%# Bind("UnitCost") %>' |
| ToolTip="Enter Unit Cost" |
| visible="false" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvUnitCost" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid amount" |
| ControlToValidate="txtUnitCost" Operator="DataTypeCheck" |
| Type="Double" ></asp:CompareValidator> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:TextBox ID="txtEnterUnitCost" Runat="server" MaxLength="10" |
| ToolTip="Enter Unit Cost" |
| ></asp:TextBox> |
| <asp:CompareValidator ID="cvEnterUnitCost" runat="server" |
| Display="Dynamic" ErrorMessage="Please enter a valid amount" |
| ControlToValidate="txtEnterUnitCost" Operator="DataTypeCheck" |
| Type="Double" ></asp:CompareValidator> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Total Cost" |
| SortExpression="TotalCost" |
| UniqueName="TotalCost"> |
| <ItemTemplate> |
| <asp:Label runat="server" ID="lblTotalCost" Text='<%# Bind("TotalCost") %>' ></asp:Label> |
| </ItemTemplate> |
| <FooterTemplate> |
| <asp:Label runat="server" ID="lblFooterTotalCost" ></asp:Label> |
| </FooterTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| <EditFormSettings> |
| <PopUpSettings ScrollBars="None" /> |
| </EditFormSettings> |
| <ExpandCollapseColumn Resizable="False" Visible="False"> |
| <HeaderStyle /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:Label ID="lblSubTotal" runat="server" ></asp:Label> |
#####################################
