Lightswitch: Custom button doesn't call method
I'm trying to add a new custom button to a view in the Lightswitch HTML client.

In the custom code for that view, the 'execute' method for that button is defined as followed (using the right click context menu to generate the signature to ensure it's correct).
/// <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');
};
The first method hides the default buttons, the second is the execution code for the button. When the button is clicked in the web client, the method does not get called, and instead of hitting it the screen loads continuously (shown below).
The AddEditLRIDetails view is called from the AddEditMainTable view. In the context of the program MainTable is effectively a parent of LRIDetails. The code for calling the view is as follows:
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();
}
});
};

How can I fix this continuous loading so that the button method is actually called?
javascript c# visual-studio-lightswitch
add a comment |
I'm trying to add a new custom button to a view in the Lightswitch HTML client.

In the custom code for that view, the 'execute' method for that button is defined as followed (using the right click context menu to generate the signature to ensure it's correct).
/// <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');
};
The first method hides the default buttons, the second is the execution code for the button. When the button is clicked in the web client, the method does not get called, and instead of hitting it the screen loads continuously (shown below).
The AddEditLRIDetails view is called from the AddEditMainTable view. In the context of the program MainTable is effectively a parent of LRIDetails. The code for calling the view is as follows:
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();
}
});
};

How can I fix this continuous loading so that the button method is actually called?
javascript c# visual-studio-lightswitch
1
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12
add a comment |
I'm trying to add a new custom button to a view in the Lightswitch HTML client.

In the custom code for that view, the 'execute' method for that button is defined as followed (using the right click context menu to generate the signature to ensure it's correct).
/// <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');
};
The first method hides the default buttons, the second is the execution code for the button. When the button is clicked in the web client, the method does not get called, and instead of hitting it the screen loads continuously (shown below).
The AddEditLRIDetails view is called from the AddEditMainTable view. In the context of the program MainTable is effectively a parent of LRIDetails. The code for calling the view is as follows:
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();
}
});
};

How can I fix this continuous loading so that the button method is actually called?
javascript c# visual-studio-lightswitch
I'm trying to add a new custom button to a view in the Lightswitch HTML client.

In the custom code for that view, the 'execute' method for that button is defined as followed (using the right click context menu to generate the signature to ensure it's correct).
/// <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');
};
The first method hides the default buttons, the second is the execution code for the button. When the button is clicked in the web client, the method does not get called, and instead of hitting it the screen loads continuously (shown below).
The AddEditLRIDetails view is called from the AddEditMainTable view. In the context of the program MainTable is effectively a parent of LRIDetails. The code for calling the view is as follows:
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();
}
});
};

How can I fix this continuous loading so that the button method is actually called?
javascript c# visual-studio-lightswitch
javascript c# visual-studio-lightswitch
edited Sep 7 '18 at 8:11
J Lewis
asked Aug 16 '18 at 10:26
J LewisJ Lewis
138212
138212
1
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12
add a comment |
1
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12
1
1
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12
add a comment |
1 Answer
1
active
oldest
votes
In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51874851%2flightswitch-custom-button-doesnt-call-method%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time
add a comment |
In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time
add a comment |
In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time
In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time
answered Nov 23 '18 at 12:45
J LewisJ Lewis
138212
138212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51874851%2flightswitch-custom-button-doesnt-call-method%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
As this issue may be connected with the way in which you're displaying the OLTP_AddEditLRIDetailsSet screen, please can you post your screen calling code
– Chris Cook
Sep 6 '18 at 19:58
@ChrisCook I've added the code
– J Lewis
Sep 7 '18 at 8:11
Rather confusingly there used to be a table called MainTable, which has since been replaced by MainTable1 (I had nothing to do with naming...)
– J Lewis
Sep 7 '18 at 8:12