PDA

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



matrixwebtech
Dec 29, 2014, 7:19 AM
Hi,I am little curious to know how can I call a direct method (http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.direct.Event-method-constructor) from client side and get returned data from the event and store in variable with getData( ) (http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.direct.Event-method-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()

Daniil
Dec 29, 2014, 3:33 PM
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:
http://examples2.ext.net/#/Events/DirectMethods/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/4.2.1/#!/api/Ext.direct.Event-method-constructor
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.direct.Event-method-getData

We have our own implementation of that in Ext.NET.

matrixwebtech
Dec 29, 2014, 6:57 PM
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.HRSystemConfiguratio n.SalaryComponentSetup",

}
);
}
}
}

Controller


namespace ERP.Controllers.HumanResource.HRSystemConfiguratio n.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.SalaryCompo nentSetup.getformula('1','2')";
})

but facing a javascript error.

17841

Area Structure
17851

Daniil
Dec 31, 2014, 1:18 PM
Could you, please, create a simple test project and upload it somewhere? Please see 7.C):
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)

matrixwebtech
Dec 31, 2014, 2:13 PM
please close this thread. I fix this my own.

Daniil
Dec 31, 2014, 2:23 PM
Could you, please, share a solution? I am interested by my own:)

matrixwebtech
Dec 31, 2014, 2:41 PM
I am doing a mistake with

.Listeners(l =>
{
l.Show.Handler = @"#{DirectMethods}.HRSystemConfiguration.SalaryCompo nentSetup.getformula('1','2')";
})

change to


.Listeners(l =>
{
l.Show.Handler = @"#{DirectMethods}.getformula('1','2')";
})