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:
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:
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:
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?
| <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); |
| } |
| } |
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?