【问题标题】:Lightswitch: Custom button doesn't call methodLightswitch:自定义按钮不调用方法
【发布时间】:2018-08-16 10:26:34
【问题描述】:

我正在尝试向 Lightswitch HTML 客户端中的视图添加一个新的自定义按钮。

在该视图的自定义代码中,该按钮的“执行”方法定义如下(使用右键单击上下文菜单生成签名以确保其正确)。

/// <reference path="~/GeneratedArtifacts/viewModel.js" />

myapp.OLTP_AddEditLRIDetailsSet.Details_postRender = function (element, contentItem) {
    $("[data-ls-tap='tap:{data.shell.okCommand.command}']").hide(); // Hide Ok Button
    $("[data-ls-tap='tap:{data.shell.cancelCommand.command}']").hide(); // Hide Cancel Button
};


myapp.OLTP_AddEditLRIDetailsSet.Test_Method_execute = function (screen) {
    console.log('execute');
};

第一种方法隐藏默认按钮,第二种是按钮的执行代码。在 Web 客户端中单击按钮时,不会调用该方法,而是连续加载屏幕而不是点击它(如下所示)。

从 AddEditMainTable 视图调用 AddEditLRIDetails 视图。在程序的上下文中,MainTable 实际上是 LRIDetails 的父级。调用视图的代码如下:

myapp.OLTP_AddEditMainTable.AddLRI_execute = function (screen) {
    myapp.showOLTP_AddEditLRIDetailsSet(null, {
        beforeShown: function (OLTP_AddEditLRIDetailsSet) {
            var newLRI = new myapp.LRIDetailsSet();
            newLRI.MainTable = screen.MainTable1;
            OLTP_AddEditLRIDetailsSet.LRIDetailsSet = newLRI;
        },
        afterClosed: function () {
            // Refreshes the content so that the filter queries are applied
            screen.OLTP_LRIDetailsSet.refresh();
            screen.OLTP_LRIDetailsSet.load();
        }
    });
};

如何解决这种持续加载的问题,以便实际调用按钮方法?

【问题讨论】:

  • 由于此问题可能与您显示 OLTP_AddEditLRIDetailsS​​et 屏幕的方式有关,请您发布您的屏幕调用代码
  • @ChrisCook 我已经添加了代码
  • 相当令人困惑的是,曾经有一个名为 MainTable 的表,后来被 MainTable1 取代(我与命名无关......)

标签: javascript c# visual-studio-lightswitch


【解决方案1】:

最后我重新创建了视图,它是父视图。以其他方式尝试修复它大约 20 小时。我对在 Lightswitch 工作的建议是不要害怕撕掉并重做,这样可以节省时间

【讨论】:

    猜你喜欢
    • 2019-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-13
    • 2012-10-27
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多