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

Returning data from RadWindow in SharePoint

2 Answers 119 Views
Window
This is a migrated thread and some comments may be shown as answers.
Russ
Top achievements
Rank 1
Russ asked on 08 May 2009, 01:40 PM
I have an application in SharePoint that contains a RadGrid whoe edit item calls a RadWindow to get some external information.  This works fine when I run through testing in my visual studio environment, but as soon as I move it it's SharePoint home, it no longer returns the data.   The main page with the RadGrid works fine, it calls the RadWindow fine (and everything in it works as expected), but once I hit the submit button, the RadWindow just closes and the data does not seem to go back to the Parent Window.  

Ive based my code on this demo, and a various other links within the documentation that I can't fnd atm.   Is there something different that needs to be done for the values to be returned to the parent window in SharePoint?  

I'll try to give the main pieces of code blow:
First, from the main form:  the RadWindow declaration:
<telerik:RadWindowManager   
        ID="RadWindowManager1" ShowContentDuringLoad="false"    
        VisibleStatusbar="false" ReloadOnShow="true" runat="server">  
        <Windows> 
            <telerik:RadWindow ID="RadWindow1" Width="350px" Height="450px" Title="Choose Assignees" 
                Behaviors="Close" OnClientClose="OnClientClose"   
                NavigateUrl="/UserControls/ProposalTasks/PeoplePickerDialog.aspx" Modal="True">  
            </telerik:RadWindow> 
        </Windows> 
</telerik:RadWindowManager> 

The field within the RadGrid that needs the data (note the inner Javascript is storing these clientIDs in an array for easy access) :
<telerik:GridTemplateColumn HeaderText="Assigned To" UniqueName="ASSIGNED_TO"   
                            SortExpression="ASSIGNED_TO" DataField="ASSIGNED_TO">  
                            <EditItemTemplate> 
                                 <script type="text/javascript">  
                                     registeredTbAssignedElements.push('<%# Container.FindControl("rtbAssigned").ClientID %>');   
                                 </script>    
                                 <telerik:RadTextBox ID="rtbAssigned" runat="server" Rows="1" Columns="50" 
                                        Text='<%#Bind("ASSIGNED_TO")%>' TextMode="MultiLine" > 
                                 </telerik:RadTextBox> 
                                 <asp:Button ID="btnGetNames" runat="server" Text="^" /> 
                            </EditItemTemplate> 
                            <ItemTemplate> 
                                <asp:Label ID="lblAssignees" runat="server"   
                                    Text='<%# Eval("ASSIGNED_TO") %>'></asp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 

The JavaScript related to the RadGrid on the arent page:
<script type="text/javascript">  
    //global DOM ID registry for our rtbAssigned control.  filled up by scripts rendered from template fields.  
    var registeredTbAssignedElements = [];  
 
    // Rad Window functionality (for selecting assignees)  
    //<![CDATA[
    function openWin(radindex) {
        var tbAssignedclientID = registeredTbAssignedElements[radindex];
        var currText = $get(tbAssignedclientID);
        var oWnd = radopen("/UserControls/ProposalTasks/PeoplePickerDialog.aspx?rowIndex=" + radindex + "&currentText=" + currText.value, "RadWindow1");
    }
    function OnClientClose(oWnd, args) {
        //get the transferred arguments
        var arg = args.get_argument();
        if (arg) {
            var radIndex = arg.indexID;
            var assignees = arg.assignees;
            var existingAssignees = $find(registeredTbAssignedElements[radIndex]);
                existingAssignees.set_value(assignees);
        }
    }
       
    
    //]]> 
</script> 

The entier RadWindow Page that is called and it's Javascript:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PeoplePickerDialog.aspx.cs" Inherits="Proposal_Tasks.UserControls.ProposalTasks.PeoplePickerDialog" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<script type="text/javascript">  
    function GetCurrentItemRequesting(sender, eventArgs) {  
        var context = eventArgs.get_context();  
        context["FilterString"] = eventArgs.get_text();  
    }  
    function GetRadWindow() {  
        var oWindow = null;  
        if (window.radWindow) oWindow = window.radWindow;  
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
        return oWindow;  
    }  
    function returnToParent() {  
        //create the argument that will be returned to the parent page  
        var oArg = new Object();  
          
        // get the Row ID  
        var textRowID = document.getElementById('txtRowID');  
        //get the names  
        var textbox = document.getElementById("<%=rtbStart.ClientID %>");   
 
        oArg.indexID = textRowID.value;  
        oArg.assignees = textbox.value;  
 
        //get a reference to the current RadWindow  
        var oWnd = GetRadWindow();  
 
        //Close the RadWindow and send the argument to the parent page  
        if (oArg.assignees) {  
            oWnd.close(oArg);  
        }  
    }  
</script> 
<head runat="server">  
    <title></title>  
 
</head> 
<body > 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
    </telerik:RadScriptManager> 
    <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" /> 
 
        <fieldset id="fld1" > 
            <legend style="text-align:center" >Choose Assignees</legend> 
            <div style="margin: 5px 0 10px 0px; text-align:center;" > 
                 <telerik:RadTextBox ID="rtbStart" runat="server" Rows="3" Columns="35" 
                        TextMode="MultiLine" > 
                 </telerik:RadTextBox> 
                <telerik:RadComboBox ID="rcbAssigned" Runat="server" AccessibilityMode="True"   
                    Width="250px"  MaxHeight="225px" ShowMoreResultsBox="True" EnableLoadOnDemand="True"   
                    OnSelectedIndexChanged="rcbAssigned_SelectedIndexChanged"   
                    OnClientItemsRequesting="GetCurrentItemRequesting"   
                    AutoPostBack="True" > 
                <WebServiceSettings Method="ListADUsers" Path="/UserControls/WebServices/WSADUsers.asmx" /> 
                </telerik:RadComboBox> 
                <input id="txtRowID" type="hidden" runat="server" /> 
            </div> 
        </fieldset> 
        <div style="margin-top: 4px; text-align:right;">  
            <button title="Submit" style="margin-top: 26px;" id="close" onclick="returnToParent(); return false;">  
            Submit</button>      
        </div> 
    </form> 
</body> 
</html> 
 
and that page's code behind, as it does a little bit of the setup work (although I don't think it's related to the problem).:
       protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                if (Request["currentText"] != null)  
                {  
                    rtbStart.Text = Request["currentText"];  
                }  
                if (Request["rowIndex"] != null)  
                {  
                    txtRowID.Value = Request["rowIndex"];  
                }  
            }  
        }  
 
        protected void rcbAssigned_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            string newval = rcbAssigned.Text;  
            // add the selected user to the listing  
            string textboxValue = rtbStart.Text;  
            if (textboxValue.Trim() == "")  
                textboxValue = newval;  
            else  
                textboxValuetextboxValue = textboxValue + "; " + newval;  
            rtbStart.Text = textboxValue;  
        } 

I know it's a lot of code to digest at once, but I need help here.  As I said, all works perfect in the Visual Studio environment, but as soon as I move it to SharePoint the return variables don't work.   Anyone have any idea whats happening?

Thanks,
Russell.



2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 11 May 2009, 01:38 PM
Hello Russell,

I examined your code and it seems to be correct. It is also strange that it works on a separate page but it does not in SharePoint. What I can suggest is to debug the client code and see whether all of it is executed.

In case this does not help, I suggest to provide a live url where I can examine the setup and research what might be causing the problem.


All the best,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Russ
Top achievements
Rank 1
answered on 11 May 2009, 04:18 PM
Unfortunately I can't provide a live URL because we only work within our Intranet behind a firewall. For the time being we have decided to put this functionality on hold (due to timing constraints on the project).  I'll try to revisit this later and give an update.

Thanks.
Tags
Window
Asked by
Russ
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Russ
Top achievements
Rank 1
Share this question
or