Returning Complex Type

8 posts, 0 answers
  1. margan
    margan avatar
    17 posts
    Member since:
    Oct 2010

    Posted 06 Apr 2011 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Apr 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. margan
    margan avatar
    17 posts
    Member since:
    Oct 2010

    Posted 06 Apr 2011 Link to this post

    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
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 06 Apr 2011 Link to this post

    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
  6. margan
    margan avatar
    17 posts
    Member since:
    Oct 2010

    Posted 06 Apr 2011 Link to this post

    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?
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 06 Apr 2011 Link to this post

    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
  8. margan
    margan avatar
    17 posts
    Member since:
    Oct 2010

    Posted 06 Apr 2011 Link to this post

    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
  9. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 07 Apr 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017