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

[Solved] Access edit form textbox of hierarchical grid on client

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 20 Apr 2009, 04:19 PM
I have a 3 level hierarchical grid where I use editforms as my edit mode. In the edit form, I have a gridtemplatecolumn which has a lookup icon and when I click on it, I open a radwindow so the user can choose a name from a list of about 5000 names. I open this window from a client handler for the icon. On close of the window, the name and id is returned, and I need to set one of the grid item template textboxes with this name. The gridtemplate column is:
<telerik:GridTemplateColumn UniqueName="feedName" HeaderText="Feed name" DataField="feed_name"
                                     <ItemTemplate> 
                                      <asp:Label ID="feed_nameLabel"   runat="server"  Text='<%#Eval("feed_name") %>'></asp:Label> 
                                     </ItemTemplate> 
                                     <EditItemTemplate> 
                                         <telerik:RadTextBox ID="feed_name" runat="server" Enabled="false" Width="175px" 
                                                    ToolTip="Click on lookup icon to choose from sources" Text = '<%# Eval("feed_name") %>'
                                                </telerik:RadTextBox> 
                                            
                                                 
                                                <asp:ImageButton ID="sourceLookUpButton" runat="server"  
                                                    AlternateText="Click to choose feed name" ImageUrl="~/Images/Lookup1.gif"  
                                                    OnClientClick="openSourceWindow(); return false;"  
                                                    ToolTip="Click to choose source"  /> 
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"  
                                                    ControlToValidate="feed_name" Display="Dynamic" ErrorMessage="* required"  
                                                    ForeColor="#003DEB" SetFocusOnError="true"  
                                                    ValidationGroup="FeedValidationGroup"></asp:RequiredFieldValidator> 
                                                  
                                      
                                     </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 

I found an example here that creates a script onitemcreate, and calls that script on the close of the window. It is giving me an error when calling the scipt. The code I use in the itemCreated handler is:
if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name == "FeedTableView"
        { 
            if (e.Item.OwnerTableView.IsItemInserted) // item is about to be inserted 
            { 
                GridEditableItem editableItem = (GridEditableItem)e.Item; 
                RadTextBox feedName = (RadTextBox)editableItem["feedName"].FindControl("feed_name"); 
                string script = String.Format("GetFeedNameID = '{0}';\n",  editableItem["feedName"].FindControl("feed_name").ClientID); 
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "mykey", script, true); 
                RadAjaxPanel1.ResponseScripts.Add(script); 
            } 
        }   
When it runs, I debug this line:
 string script = String.Format("GetFeedNameID = '{0}';\n",  editableItem["feedName"].FindControl("feed_name").ClientID);
which gets the clientID of a gridtemplatecolumn

it and see that the script gets set with the value:
 "GetFeedNameID = 'providersGrid_ctl00_ctl09_Detail20_ctl09_Detail20_ctl02_ctl04_feed_name';\n"


In the client in the radwindow onclientclose handler, I call:
function OnClientSourceClose(oWnd) { 
 
             var txtbxSourceName; 
             var txtbxSourceID; 
             if (oWnd.argument.returnCode == 0)  // if returnCode is 0, user cancelled - don't change anything 
                 return
 
             if (oWnd.argument.returnCode == -1) // user pressed clear - clear out values 
             { 
                 txtbxSourceName = $find("source_name"); 
                 txtbxSourceName.set_value(""); 
                 txtbxSourceID = $find("source_id"); 
                 txtbxSourceID.set_value("-1"); 
                 return
             } 
             //get the transferred arguments 
             var source_name = oWnd.argument.sourceName; 
             var sourceId = oWnd.argument.sourceID; 
 
             $get(GetFeedNameID).innerHTML = source_name;   
         } 

The last statement $get(GetFeedNameID).innerHTML = source_name; is calling the script
and it It throws the error: htmlfile: Unknown runtime error

What am I doing wrong?


1 Answer, 1 is accepted

Sort by
0
Laura
Top achievements
Rank 1
answered on 20 Apr 2009, 05:28 PM
Ok, I figured out how to fix it. I changed my RadTextBox in the template column to a asp textbox, and instead of setting it using innerhtml, I set it's value, so I changed the line to

$get(GetFeedNameID).value= source_name;

and now it works.
Tags
Grid
Asked by
Laura
Top achievements
Rank 1
Answers by
Laura
Top achievements
Rank 1
Share this question
or