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

Returning Complex Type

7 Answers 94 Views
Window
This is a migrated thread and some comments may be shown as answers.
margan
Top achievements
Rank 1
margan asked on 06 Apr 2011, 10:02 AM
Hi,

My problem is that on my opened RadWindow I have a RadGrid.
Is it possible to return a complex list of object to parent?
Lets say my grid has 3 columns (1 checkbox and 2 string ones)
Can I return something like datasource or create custom class in js?
Should I iterate through the radgrid items?
Any code sample would be great.

Thanks

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Apr 2011, 10:28 AM
Hello Margan,

The RadWindow provides methods for communication between the RadWindow and the parent. For this you need to subscribe to the following functions.
  •  OnClientClose.
  • OnClientShow
You can find the detailed description from here. Using RadWindow as a Dialog

Thanks,
Shinu.
0
margan
Top achievements
Rank 1
answered on 06 Apr 2011, 10:40 AM
Hi Shinu,

I already implemented the communication and I can return simple types like string.
My problem is that I would like to return more complex type.
What I want to do is to return data from RadGrid in that opened RadWindow.
My question is how to get that data from RadGrid in my js ReturnToParent function.
I need to extract that data from RadWindow and on my parent page I have to create a new RadGrid using this extracted data.

Thanks
0
Marin Bratanov
Telerik team
answered on 06 Apr 2011, 11:32 AM
Hi Sebastian,

You can return any object you create in the RadWindow to the main page when you close it. How you are going to create that object and then interpret its value depends on your custom scenario.

To see how to transfer objects after the window is closed take a look at the following demo: http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx and more notably the returnToParent() function in Dialog1.aspx. This object is retrieved in the OnClientClose() event handler in the main page.


Greetings,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
margan
Top achievements
Rank 1
answered on 06 Apr 2011, 01:42 PM
Hi,

Yes I used that example earlier.
But I was wondering how i can for example iterate through DataGrid and return to parent a list of strings for example.
Nevertheless now I have this kind of problem.
I've returned simple text from my RadWindow and now I want to add it to a ListBox.
The js sample code looks like this:

function OnClientClose(oWnd, args) {
    var arg = args.get_argument();
    if (arg) {
        var custom = arg.custom;
        var itemT = new Telerik.Web.UI.RadListBoxItem();
    }
}

But this fails and I get Telerik.Web.UI.RadListBoxItem is not a constructor

Any ideas why?
0
Marin Bratanov
Telerik team
answered on 06 Apr 2011, 02:03 PM
Hello Sebastian,

The Telerik Controls are server controls, which means that you cannot dynamically create them via JavaScript, but only through server-side code (as any other server control).


Greetings,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
margan
Top achievements
Rank 1
answered on 06 Apr 2011, 02:18 PM
Thanks Marin,

I was just referring to code from http://demos.telerik.com/aspnet-ajax/listbox/examples/clientside/addremovedisable/defaultcs.aspx
where the function is in javascript like this:

function addItem() {
                var itemText = $find("<%= RadTextBox1.ClientID %>").get_value();
                if (!itemText) {
                    alert("Please specify the text for the new item.");
                    return false;
                }
 
                listBox.trackChanges();
                //Instantiate a new client item
                var item = new Telerik.Web.UI.RadListBoxItem();
                item.set_text(itemText);
                item.set_selected(true);
 
                listBox.get_items().add(item);
                item.scrollIntoView();
                listBox.commitChanges();
                return false;
            }

So it can't be done? When I use the RadWindow and return some values from it I can't populate any RadListControl with it? It works only when populating simple textboxes or something like that?

Thanks
0
Marin Bratanov
Telerik team
answered on 07 Apr 2011, 12:12 PM
Hello Sebastian,

On my end this seems to be working fine. You can find my test page attached as a reference. Here is a video from my experiment: http://screencast.com/t/9lXbWKQG3HbG.
If you are still experiencing difficulties modify my page until it displays the unusual behavior and send it back.


All the best,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
margan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
margan
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or