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

How to use the data passed to a window.

3 Answers 1156 Views
Window
This is a migrated thread and some comments may be shown as answers.
Satish
Top achievements
Rank 1
Satish asked on 26 Mar 2012, 03:59 PM
I'm opening a kendo window with a ajax content and I'm also passing some data into the window as shown below. 
 
if (!window.data("kendoWindow")) {
                  window.kendoWindow({
                      content: {
                          url: "selectcontact.htm",
                          data: {
                              op1: agencyId,
                              op2: agencyName
                          }
                      },
                      title: "Select a Contact",
                      actions: ["Refresh", "Close"],
                      visible: false,
                      modal: true,
                      close: onClose
                  });

Now within selectcontact.htm how do I access the op1 and op2 ? I have a kendo combobox thats bound to an oData service and I the need to pass op1 into the uri. 

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 27 Mar 2012, 08:32 AM
Assuming that you are not using any server-side technology, the selectcontact.htm page will not be able to use any of the data, because it is fetched through AJAX and is directly inserted in the page. However, because it is loaded in the same browser frame, the loaded content has access to any global variables and functions, so you might just use he agencyId (if it is global, or if you make it global). Note that providing some abstraction around the variables will prevent the global scope from being polluted.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Joshua
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 07 Jun 2012, 08:19 PM
How would you provide abstraction around the variable? My problems is that I am setting up everything inside of my document ready, $(function(){...}); But then i dont have acccess to the variables that i create.
0
Joshua
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 07 Jun 2012, 08:34 PM
It should be noted that i use a hacky method

I am using .NET

in the window call i pass in the url and the data:
        win.kendoWindow({<br>            content: { type: "POST", url: url, data: { "JSON": kendo.stringify(dataObjectToPass) }}<br>        }).data("kendoWindow").center().open();<br>

in my aspx I have a:
var JSON = jQuery.parseJSON('<%=Me.JSON %>');


in my code behind I have a:    
Public ReadOnly Property JSON As String<br>        Get<br>            Return HttpUtility.UrlDecode(CStr(Request("JSON")))<br>        End Get<br>    End Property
Tags
Window
Asked by
Satish
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Joshua
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or