[SOLVED] need a sample on how to transfer data from Wisej to a javascript application running in an iFrame and vice versa

Answered
0
0

Hello to All,

to clarify what I mean is, let’s say I have a grid and want take some data from the grid, call an iFrame with a javascript application and make there the data from  the grid available for the javascript app.

After doing something with the data in javasript, I would like to send back the changes to my grid for update.

A sample showing the mechanics of the data movements between Wisej/javascript would be very appreciated.

Best regards

Johann

  • You must to post comments
Best Answer
0
0

See attached.

I added a sample function to your IFramePanel1 control using the JavaScript component extender:

 

this.setValue = function(value, id)
{
    debugger;
    
    var frameDoc = this.getDocument();
    if (!frameDoc)
    {
        this.addListenerOnce("load", function(e){
            this.setValue(value, id);
        });
    }
    else
    {
        var el = frameDoc.getElementById(id);
        if (el)
            el.innerText = value;
    }
}

Then you can call this.iFramePanel1.Call(“setValue”, “value”, “id”);

This is relatively easy because Wisej exposes a lot of functionality. Otherwise with plain vanilla javascript it becomes quite messy. You need to consider that the iframe is not loaded instantaneously, that the elements may not be there, etc.

 

 

Attachment
  • You must to post comments
0
0

Hello Luca,

I added a sample where you can see what I want to know. It would be great if you can fill up the missing parts.

Thank you

Johann

Attachment
  • You must to post comments
0
0

If the iframe is from the same domain you can call javascript directly using window.frames[index] and from the frame up using window.parent.

If the iframe from a different domain you need to use postMessage, otherwise the browser will block you.

From the server side in Wisej you can call any javascript function using Control.Call or Eval on a specific control or Application.Call/Eval for a general call.

If the iframe is a Wisej.Web.IFramePanel on the server, then on the client it exposes getWindow() and getDocument() to the get window and the document objects from the iframe (works only from the same domain).

If you attach a test case showing what you need and leaving out the parts that you need help with it would help me understand better.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.