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

[Solved] client side - get textbox parentnode id

2 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prathibarani
Top achievements
Rank 1
Prathibarani asked on 28 May 2013, 07:08 PM

Hi,

 

My grid has template column with textbox in item template and textbox in footer template. The aspx looks like this:

 

<telerik:GridTemplateColumn AllowFiltering="False" FilterControlAltText="Filter Amount column" Groupable="False" HeaderText="Amount" Reorderable="False" ShowFilterIcon="False" UniqueName="Amount" HeaderTooltip="Amount">

    <HeaderStyle Width="17%"></HeaderStyle>

    <ItemTemplate>

       <asp:TextBox ID="txtAmount" runat="server" Width="75%" CssClass="rightalign" onblur="return txtAccountAmount_Blur
                                                                                                            (event);"
/>

    </ItemTemplate>

    <FooterTemplate>

       <asp:Literal ID="Literal1" runat="server" ><span style='color: Black; font-weight:

                     bold;'>Sum:</span></asp:Literal>

       <asp:TextBox ID="txtAmountTotal" runat="server" Width="75%" CssClass="rightalign" />

    </FooterTemplate>

</telerik:GridTemplateColumn>

 

Then I have function on this local aspx page as:

function txtAccountAmount_Blur(evnt){

    var txtBox = ((evnt.target) ? evnt.target : evnt.srcElement);

    var isValid = Currency_Validate( txtBox );

    SetGridCurrencyTextBoxError(isValid, txtBox, evnt);

    return isValid;

}

       

 

In global javascript:

 

function SetGridCurrencyTextBoxError(isValid, txtBox, evt){

    var cell = txtBox.parentNode;

 

    var errorMsg = document.getElementById(cell.id + "_spnError");

 

    if(!isValid){//Was not valid currency value.

        if(!errorMsg){

            errorMsg = document.createElement('span');

            errorMsg.className = 'inlineerrortext';

            errorMsg.innerHTML = 'Invalid currency value.';

            errorMsg.id = cell.id + "_spnError";

            cell.insertBefore(errorMsg, txtBox);

        }

 

}

 

Cell.id is always empty. I used developer tools to debug. There is textbox id. I see it. It is something like this:

Ctl00_maincontent_rgdAccounts_ctl00_ctl04_txtAmount . As far as I know, parent id should be - Ctl00_maincontent_rgdAccounts_ctl00_ctl04

 

Please let me know how to get id of parentnode

 

Thanks,

Prathiba

2 Answers, 1 is accepted

Sort by
0
Prathibarani
Top achievements
Rank 1
answered on 28 May 2013, 07:11 PM
Forgot to say that, I know I can use RadNumeric Textbox. But user's are used to see it like this because we used this code with other vendor grids. RadNumericTextbox shows warning image within textbox. It wouldn't display text.
Since I am using textbox only with Radgrid, I am thinking there shouldn't be any problem in getting parent node.


Thanks,
Prathiba
0
Prathibarani
Top achievements
Rank 1
answered on 28 May 2013, 09:05 PM
I found solution. Instead of using cell.Id, I used cell.uniqueID. It is working now. I am not sure whether it is OK to use uniqueID or not.

Thanks,
Prathiba.
Tags
Grid
Asked by
Prathibarani
Top achievements
Rank 1
Answers by
Prathibarani
Top achievements
Rank 1
Share this question
or