This is a migrated thread and some comments may be shown as answers.
Window component client-side API
2 Answers 104 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carlos
Top achievements
Rank 1
Carlos asked on 20 Aug 2010, 11:55 AM
Hi

I've been playing with the Window component. In a single View I need 2 modal windows: one will show an 'add new item' form, and the other one will display an 'edit item' form. Both should be opened from links. And problems started :)

1) If I create the 1st one server-side, and just use the open client API, then the 2nd never displays the overlay. In addition, the center() function, when called via the client API, is just a bit wrong. Calling .Center() in the server-side fluent interface works OK.

2) The 2nd one can't be created server-side, because its contents depend on the 'item' being clicked, and I don't see any client-API method equivalent to LoadContentFrom.  I inspected the telerik.window.js code before posting.

So I decided to create both client-side on the fly, and here are the problems:

1) If I don't declare any server-side Window object, the $.telerik.window JS code is not loaded at all, so $.telerik.window doesn't exist.
2) If I declare a dummy hidden window in order to get the JS library loaded, the overlay problem still exists. I've noticed that the FIRST modal window works, but after closing it, the following will be non-modal.

I've been trying to solve this for some time now, anyone have idea before I quit and use another Dialog component from the dozens available online? :)

Here's my code anyway:

<script type="text/javascript">
    //Called from a button link to add a new item
    function openAddForm(idfactura) {       
        var windowElement = $.telerik.window.create({
            name: "AddItem",
            title: "AƱadir detalle",
            contentUrl: '/DetalleFacturas/Create/' + idfactura,
            modal: true,
            resizable: false,
            draggable: false
        });
        windowElement.data("tWindow").center();
        return false;
    }
 
    //called from each of the items link to open the edit form
    function openEditItemForm(idfactura, iditem) {
        var windowElement = $.telerik.window.create({
            name: "EditItem",           
            title: "Editar detalle",
            contentUrl: '/DetalleFacturas/Edit/' + idfactura + '/' + iditem,
            modal: true,
            resizable: false,
            draggable: false           
        });
 
        windowElement.data("tWindow").center();       
        return false;
    }
</script>

Edit: I'm using the 2010 Q2 2010 Beta extensions, of course. :) Apart from this everything else is *great*

Thanks, best regards.

2 Answers, 1 is accepted

Sort by
0
Carlos
Top achievements
Rank 1
answered on 25 Aug 2010, 09:42 AM
Seems I posted in the wrong forum. May some admin move this to the Window forum? :)
0
Stefan
Top achievements
Rank 1
answered on 22 Nov 2010, 08:43 AM

When only calling window on the client side you have to register the window-script manually.

 

<% Html.Telerik().ScriptRegistrar()

 

 

.Scripts(scripts => scripts.Add("2010.3.1110/telerik.window.js"))

 

.Render();

%>

Tags
General Discussions
Asked by
Carlos
Top achievements
Rank 1
Answers by
Carlos
Top achievements
Rank 1
Stefan
Top achievements
Rank 1
Share this question
or