[CLOSED] DirectEvent: Call from clientside and getData()

  1. #1

    [CLOSED] DirectEvent: Call from clientside and getData()

    Hi,I am little curious to know how can I call a direct method from client side and get returned data from the event and store in variable with getData( ) .

    May be I am wrong ,please correct me.
    <script>
            var callDirectMethod=function()
            {
                //How I call a directmethod and consume return data from method
            }
        </script>
     @(X.Button()
            .Listeners(l =>
            {
                l.Click.Handler = "callDirectMethod";//This method I declare on clint side 
            })
            )
      public DirectResult samplemethod()
            {
                //some code and finaly will return some data.
                return this.Direct();
            }
    I want to call samplemethod from callDirectMethod and consume return data with. getData()
    Last edited by Daniil; Dec 31, 2014 at 2:23 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    To deal with a server response you should use a success and a failure handlers.

    There is an example with a success handler. Please see #2 here:
    https://examples2.ext.net/#/Events/D...thods/Overview

    By the way, please note that Ext.NET DirectEvens and DirectMethods are not related to the links that you mentioned:
    http://docs-origin.sencha.com/extjs/...od-constructor
    http://docs-origin.sencha.com/extjs/...method-getData

    We have our own implementation of that in Ext.NET.
  3. #3
    Hi danill thanks for reply,but there are something I am not able to fix please help.
    I use Area in my project bellow is area registration code

    using System.Web.Mvc;
    
    namespace ERP.Areas.HumanResource
    {
        public class HumanResourceAreaRegistration : AreaRegistration
        {
            public override string AreaName
            {
                get
                {
                    return "HumanResource";
                }
            }
    
            public override void RegisterArea(AreaRegistrationContext context)
            {
                context.MapRoute(
                    "HumanResource_default",
                    "HumanResource/{controller}/{action}/{id}",
                    new { action = "Index", id = UrlParameter.Optional },
                    namespaces: new[] { "ERP.Controllers.HumanResource.HRSystemConfiguration.SalaryComponentSetup",
                                       
                    }
                );
            }
        }
    }
    Controller

    namespace ERP.Controllers.HumanResource.HRSystemConfiguration.SalaryComponentSetup
    {
       
        [DirectController(AreaName = "HumanResource")]
        public class SalaryComponentSetupController : Controller
        {
    public ActionResult Index(string id)
            {
                   return view(view_path);
            }
    
    [DirectMethod]
            public void getformula(Int64 p1, Int64 p2)
            {
    
            )
    View Code
    .Listeners(l =>
    {
        l.Show.Handler = @"#{DirectMethods}.HRSystemConfiguration.SalaryComponentSetup.getformula('1','2')";                  
    })
    but facing a javascript error.

    Click image for larger version. 

Name:	2.png 
Views:	8 
Size:	3.5 KB 
ID:	17841

    Area Structure
    Click image for larger version. 

Name:	1.png 
Views:	10 
Size:	18.7 KB 
ID:	17851
  4. #4
    Could you, please, create a simple test project and upload it somewhere? Please see 7.C):
    Forum Guidelines For Posting New Topics
  5. #5
    please close this thread. I fix this my own.
  6. #6
    Could you, please, share a solution? I am interested by my own:)
  7. #7
    I am doing a mistake with
    .Listeners(l =>
    {
        l.Show.Handler = @"#{DirectMethods}.HRSystemConfiguration.SalaryComponentSetup.getformula('1','2')";                 
    })
    change to
    .Listeners(l =>
    {
        l.Show.Handler = @"#{DirectMethods}.getformula('1','2')";                 
    })

Similar Threads

  1. Replies: 7
    Last Post: Sep 02, 2016, 7:47 PM
  2. [CLOSED] How can I get this destroy call to render in a DirectEvent?
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 06, 2014, 1:46 PM
  3. [CLOSED] Call Server DirectEvent from ExtJs
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Apr 12, 2013, 12:52 PM
  4. Replies: 4
    Last Post: Apr 09, 2013, 4:03 PM
  5. [CLOSED] Call remote WebService via DirectEvent
    By macap in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 06, 2011, 1:44 PM

Posting Permissions