PDA

View Full Version : How does Ext.Net 7 support Asp.Net Core MVC development model



Aiken
Apr 09, 2020, 1:03 AM
It looks like Ext.Net 7 is missing some features,such as:

1. Use X.AddScript to write Javascript code to client.



namespace Ext.Net.MVC.Examples.Areas.Form_TextField.InputMas k_Native.Controllers
{
public class InputMask_NativeController : Controller
{
public ActionResult Index()
{
return View();
}

public ActionResult HandleBtnClick()
{
var pattern = "99/99/9999";

// Getting the TextField dynamically does not mean its input mask will not be null,
// so the only way here is to call the actual client-side scripts.
X.AddScript("App.TextField1.setNote('" + pattern + "');");
X.AddScript("App.TextField1.inputMask.setPattern('" + pattern + "');");

return new DirectResult();
}
}
}


2. Use this.GetCmp<>() to get a proxy of client component, and invoke the method of proxy to generate client calls.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Ext.Net.MVC.Examples.Areas.GridPanel_ComponentColu mn.Overview.Controllers
{
public class OverviewController : Controller
{
public ActionResult Index()
{
return View(TestData.GetData());
}

public ActionResult DoTasks(string tasks)
{
var tasksDict = JSON.Deserialize<Dictionary<string, string>[]>(tasks);
var store = this.GetCmp<Store>("StoreTasks");

foreach (var task in tasksDict)
{
var id = JSON.Deserialize<int>(task["TaskID"]);
var progress = JSON.Deserialize<float>(task["Progress"]);
var status = JSON.Deserialize<int>(task["Status"]);

var record = store.GetById(id);
record.BeginEdit();

if (status == 1)
{
record.Set("Status", 2);
}

progress += 0.2f;

record.Set("Progress", progress);

if (progress >= 1)
{
record.Set("Status", 3);
}

record.EndEdit();
}

return this.Direct();
}
}
}


It would be useful to have an article about the MVC development model.

fabricio.murta
Apr 09, 2020, 4:20 AM
Hello @Aiken, and welcome to Ext.NET forums, and thanks for your interest and feedback about Ext.NET for ASP.NET Core!

Your affirmations are right, there are still missing bits and pieces we will definitively implement for the final version of Ext.NET Core.

I see by your message you are specially concerned with direct events, so you may also be interested in following our public GitHub issue #1713 about DirectEvent support (https://github.com/extnet/Ext.NET/issues/1713).

There you'll see a possible approach for attaining the second point of your suggestion. Currently Ext.NET Core is not "posting back" everything in the page each direct event, so you'd need to pass the component the way it is suggested here (https://github.com/extnet/Ext.NET/issues/1713#issuecomment-609511684). Then you'll be able to interact with it.

Nothing is written in stone, but it is likely many of the approaches we followed in Ext.NET 5 and back will not make it to Ext.NET Core unless they are really useful. It may be that we implement the this.GetCmp<ComponentType>() but at this point we can't ascertain of that, maybe there's just a better way to pass and access components around.

You are more than welcome to open issues in GitHub (or post threads here) for features you are missing, and they will be seriously considered for the upcoming release. For that bit (X.AddScript and this.GetCmp()), maybe we should wait a little more until issue #1713 above is marked as done before we open specific feature issues for them. I'll point the issue to this thread with the two suggestions you made.

Thanks again for your feedback, and keep them coming, we really appreciate it!

Aiken
Apr 09, 2020, 2:52 PM
I have noticed that Ext.Net 7 support direct event for razorpage development model, but I don't know if I can send direct event to controller action and got a DirectActionResult.

fabricio.murta
Apr 10, 2020, 1:53 AM
Hello @Aiken!

I understand you may be missing it as this is really not there yet. As one of the mandatory items to assume Direct Events is implemented in Ext.NET 7, is having means for it to work from MVC the way you described (as it works in current, Ext.NET 5). The final product should not change much in regard to MVC concept, so if you have a github account, follow that issue and you'll be notified when we fully implement the Direct Methods and Events to Ext.NET 7.

The point you raised is relevant and currently we don't have a specific setting for the MVC model, like OnEvent or DirectEvents.<Event>.Url.Action(string), or OnDirectClickUrl=string as we do in Ext.NET MVC.

And in case the implementation that makes it to Ext.NET 7 is not the same as the previous versions, we will have it documented in some kind of upgrade guide we are also working with, based on what we have in Examples Explorer.

Again, many things may change from this point, and the feedback from the community (like yours) should weigh a lot on what may or may not become different, be or not be included at all.

Hope this helps!

Aiken
Apr 10, 2020, 2:42 AM
Your replies is very helpful, thank you!