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

Get value of hidden RadNumericTextbox in JS

2 Answers 261 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amanda
Top achievements
Rank 1
Amanda asked on 22 Nov 2010, 09:46 PM
I am trying to get the value of radnumerictextbox in javascript.  When I set visible = true - it works fine.

Code creating the hidden field:

<

 

telerik:GridTemplateColumn DataField="RequestedHidden" Visible="false" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"

 

 

UniqueName="Requested" HeaderText="Requested" ShowSortIcon="false">

 

 

<EditItemTemplate>

 

 

<telerik:RadNumericTextBox ID="tbxReqHidden" Value='<%#Bind("Requested") %>' CssClass="RightAlign"

 

 

runat="server" Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"

 

 

Width="90px" MinValue="0" DataType="System.Int32" Enabled="false" Visible="false" >

 

 

</telerik:RadNumericTextBox>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

Here is the JS:

 

 

function RequestedTotal(sender, args) {

 

 

var rdgrid = $find("<%=RadGrid1.ClientID %>");

 

 

var cell = sender.get_element().parentNode.parentNode;

 

 

var index = cell.parentNode.rowIndex;

 

 

var MasterTable = rdgrid.get_masterTableView();

 

 

var original = MasterTable.get_dataItems()[index - 2].findControl("tbxReqHidden");

 

tempValueRequested = sumInputRequested.get_value() - original;

sumInputRequested.set_value(tempValueRequested + sender.get_value());

}

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2010, 08:22 AM
Hello,


How about hiding the RadNumerictextBox using CSS?

Style:
    <style type="text/css">
        .hideMe
        {
            display: none !important;
        }
    </style>

Set the CssClass for the RadNumerictextBox as 'hideMe'.

Also check this documentation which describes how to get the cell value from client side. Which means you can directly access the cell value (if there shown in cell) without accessing the textbox control.
Getting cell values for selected rows client side



-Shinu.
0
Amanda
Top achievements
Rank 1
answered on 23 Nov 2010, 03:20 PM
This is how I got it to work:

HTML:
<telerik:GridTemplateColumn  DataField="RequestedHidden" Display="false" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
                                UniqueName="RequestedHidden" HeaderText="Requested Hidden" ShowSortIcon="false">
                                <ItemTemplate>
                                    <telerik:RadNumericTextBox ID="tbxReqHidden" Value='<%#Bind("Requested") %>' CssClass="RightAlign"
                                        runat="server" Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"
                                        Width="90px" MinValue="0" DataType="System.Int32" >
                                    </telerik:RadNumericTextBox>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right" Width="100px" CssClass="BorderRight BorderBottom" />
                                <FooterStyle CssClass="BorderRight BorderBottom" />
                            </telerik:GridTemplateColumn>

JS:
function RequestedTotal(sender, args) {
        var rdgrid = $find("<%=RadGrid1.ClientID %>");
        var cell = sender.get_element().parentNode.parentNode;
        var index = cell.parentNode.rowIndex;
        var MasterTable = rdgrid.get_masterTableView();
        var row = MasterTable.get_dataItems()[index - 2]; //getting row
        var originalRequested = row.findControl("tbxReqHidden").get_value();
        var newValueRequested = row.findControl("tbxReq").get_value();
        var combined = originalRequested - newValueRequested;

        var tbxReqHidden = MasterTable.get_dataItems()[index - 2].findControl("tbxReqHidden");
        tbxReqHidden.set_value(newValueRequested);
        tempValueRequested = sumInputRequested.get_value() - (combined);
        sumInputRequested.set_value(tempValueRequested);
    }
Tags
General Discussions
Asked by
Amanda
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Amanda
Top achievements
Rank 1
Share this question
or