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

Querystring lost

7 Answers 158 Views
Window
This is a migrated thread and some comments may be shown as answers.
Karl Mikesell
Top achievements
Rank 1
Karl Mikesell asked on 10 Feb 2012, 07:13 PM
Loading content with querystring parameters

content:
"../../content/web/window/ajax/ajaxContent.html?op=b3A9bGlzdCZpZD03MTUwNmY4Ni1jODk3LTQ3MjItYjcxNy01OTgxNWNiZmQxNmI="

The problem since Kendo Window is loaded as an XHR, the rquestUrl is not visable to the script running inside the Content.html (i.e. location.search) page.  Ideas on passing parameters to Kendo Windows?

7 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 15 Feb 2012, 02:53 PM
You can supply any number of $.ajax parameters as the content configuration option. To illustrate,

$(...).kendoWindow({
    content: {
        url: "ajaxContent.html?op=b3A9bGlz",
        type: "GET"
    }
});


or

$(...).kendoWindow({
    content: {
        url: "ajaxContent.html",
        data: {
            op: "b3A9bGlz"
        }
    }
}); 


The same can be used when calling the refresh method.

Regards,
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
Karl Mikesell
Top achievements
Rank 1
answered on 15 Feb 2012, 07:44 PM
So, how is the data: { } accessed post-request after response from server.  The web server sees the querystring, but the Javascript afterwards does not?

The Javascript <script> tags are loaded as part of the the dynamic window content, but needs to know what was requested post-request.  Current workaround is to have web server embed hidden control with data: {} as part of the dynamic window content.  Would be nice to exclude if the initial request  is accessible.

Example: data : { page : "5" }

The refresh data could be: data : { page : "4" } or data : { page : "6"}; but this requires knowing the orginal request was page : " 5".

The workaround embeds page : "5" into a hidden control; which is used by the JavaScript.

Looking for another way to get information, without any server-side code.
0
Alex Gyoshev
Telerik team
answered on 17 Feb 2012, 08:11 AM
You could maintain the state in a JavaScript variable on the page, instead of returning it from the server.

var currentPage = window.currentPage = 5;

$(...).kendoWindow({
    content: {
        url: "ajaxContent.html",
        data: {
            page: currentPage
        }
    }
}); 

// next time, use currentPage +/- 1 

Greetings,
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
Karl Mikesell
Top achievements
Rank 1
answered on 17 Feb 2012, 04:10 PM
The problem with this method is when multiple Kendo Windows are opened, the Global variable currentPage is corrupted for all windows. 

This is why the server-code embeds a hidden field, so multiple windows can be opened and know their instanance of page and content.  Content selection is made from nodes within a Kendo TreeView, so it is likely to have multiple windows open.  Once windows are open client may proceed to change pages independently.

Will still stay with server-side code for now, since it appears to be the only way to meet the above requirements.

0
Accepted
Alex Gyoshev
Telerik team
answered on 17 Feb 2012, 05:18 PM
Hello Karl,

Indeed, the global variable is far from perfect. In your scenario, you can attach the data to the window object, using jQuery.data:

var windowElement = $(...);
windowElement.data("page", 5);

windowElement.kendoWindow({
    content: {
        url: "ajaxContent.html",
        data: {
            page: windowElement.data("page")
        }
    }
});  


This way, the data will be attached to the DOM, being set once per window.

Regards,
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
Yale
Top achievements
Rank 1
answered on 20 Jul 2012, 12:26 AM
I'm fairly new to javascript development, but I think I'm running into the same problem using the PanelBar's 'contentUrls' configuration option. I have a PanelBar in "NotificationPanel.html" where each panel contains information for a specific day. The ContentUrls for each of the panels all point to "Notifications.html" with parameters passed through the querystring. But in the javascript for "Notifications.html", the only URL I can get is "NotificationPanel.html". Do you have any suggestions on how to accomplish what I need since PanelBar contentUrls don't seem to have a data parameter?

Thanks.
0
Kamen Bundev
Telerik team
answered on 24 Jul 2012, 07:46 AM
Hi Yale,

Can you post a sample of the issue you're having?

Kind regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
Karl Mikesell
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Karl Mikesell
Top achievements
Rank 1
Yale
Top achievements
Rank 1
Kamen Bundev
Telerik team
Share this question
or