PDA

View Full Version : [CLOSED] DirectMethod function: I wish cascading calls and receive returns.



supera
Apr 02, 2012, 6:42 PM
Hi!

I have a main page with two ext:panels. In each panel, I'm loading a page.
The idea is that the first page contains filters and the second page contains a grid with data.
I'd like that before grid refresh, is received the selected filters in filter page.

But I do not know how to get the result of the function.
I call the directMethod with Ext.Net.X.Js.Call.

The grid Page call a directMethod function in Main Page and Main Page call a directMethod function in Filter Page.

I donīt following the example in http://examples2.ext.net/#/Events/DirectMethods/Overview/ because I need that result is returned in a sub or function, because I need work over the return.

I made a simple sample.

Main Page (test50.aspx)


<%@ Page Language="vb" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
<DirectMethod()>
Public Function GetValueInTest50() As String

Ext.Net.X.Msg.Alert("GetValueInTest50", "Here, I want call the directmethod function in Test51 aspx Page and and return the result to Test52 aspx Page.").Show()
Return ""
End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test 50</title>
</head>
<body>
<ext:ResourceManager ID="resManagerExplorerWEB" runat="server" Locale="pt-BR" />
<form id="form1" runat="server">
<ext:Viewport runat="server" ID="viewPort2" Layout="BorderLayout">
<Items>
<ext:Panel ID="panelLeft" runat="server" Region="West" Flex="1" Width="300" MinWidth="300" MaxWidth="350" Split="true" layout="AnchorLayout" BodyPadding="0">
<Loader ID="loadFilter" runat="server" Mode="Frame" Url="test51.aspx">
<LoadMask ShowMask="true" Msg="Carregando..."/>
</Loader>
</ext:Panel>
<ext:Panel ID="panelCenter" runat="server" Region="Center" Flex="1" layout="FitLayout" BodyPadding="0">
<Loader ID="loadPanel" runat="server" Mode="Frame" Url="test52.aspx">
<LoadMask ShowMask="true" Msg="Carregando..."/>
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


Page that needs the function value of directmethod function (test52.aspx)


<%@ Page Language="vb" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub CallGetValueInTest50()

'Ext.Net.X.Js.Call("parent.App.direct.GetFilter({success: function(result){ App.txtExternalFilter.setValue(result); alert(App.txtExternalFilter.getValue());}});")

Ext.Net.X.Msg.Alert("CallGetValueInTest50", "Here, I want call the directmethod function in Test50 aspx Page and receive the return of the function for set in lblResult.").Show()

End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerExplorerWEB" runat="server" Locale="pt-BR" />
<form id="form1" runat="server">
<div>
<ext:Viewport runat="server" ID="viewPort2" Layout="AbsoluteLayout">
<Items>
<ext:Label runat="server" ID="lblTitle" X="10" Y="5" Text="Test52 aspx Page" />
<ext:Button runat="server" ID="bt1" X="10" Y="45" Text="Call 'GetValue' in Test51.aspx page'" OnDirectClick="CallGetValueInTest50" />
<ext:Label runat="server" ID="lblResult" X="10" Y="95" />
</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>


Page that contains the value to be rescued by directmethod function (test51.aspx)


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test51.aspx.vb" Inherits="WebApplication3.Test51" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

<DirectMethod()>
Public Function GetValueInTest51() As String
Return txt1.Text
End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test 51</title>
</head>
<body>
<ext:ResourceManager ID="resManagerExplorerWEB" runat="server" Locale="pt-BR" />
<form id="form1" runat="server">
<ext:Viewport runat="server" ID="viewPort2" Layout="AbsoluteLayout">
<Items>
<ext:Label runat="server" ID="lblTitle" X="3" Y="5" Text="Test51 aspx Page" />
<ext:Label runat="server" ID="lbl1" X="3" Y="45" Text="This page contains a directmethod function called 'GetValue' which should return the value of the textfield." />
<ext:TextField runat="server" ID="txt1" X="3" Y="105" FieldLabel="Source value" Text="50" />
</Items>
</ext:Viewport>
</form>
</body>
</html>

Vladimir
Apr 02, 2012, 6:58 PM
I am affraid that such scenarion is not supported by DirectMethods
I suggest to use DirectMethod/DirectEvent when it is required only (when server side handling is required)
Extract value from a field can be accomplished on the client side without direct method

supera
Apr 02, 2012, 7:02 PM
Is there any way I can do what I want?

Vladimir
Apr 02, 2012, 7:07 PM
You have to do all on the client side (as much as possible), extracting field values, set text to label and etc, all of that can be accomplished on the client side via javascript

DirectMethod si not designed to call another direct method

supera
Apr 02, 2012, 7:12 PM
I do not have experience in JavaScript, but I can find the web the commands.

But I need a way or example on how to access the components of a page from another page, in cliente side.

Daniil
Apr 02, 2012, 7:25 PM
But I need a way or example on how to access the components of a page from another page, in cliente side.

Please see:
http://examples2.ext.net/#/Panel/Basic/IFrame_Communication/

supera
Apr 02, 2012, 7:37 PM
Ok! I try do this... thanks...