0

Can anybody help in calling the screen.showTab("TabName") using the JQuery! I am using Visual Studio 2015 Community Edition.

The same event is getting triggered from the .lsms.cs file but not .htm file (Inside the Script tag)

The way I am calling the showTab method from .lsml.cs is,

$(screen).on('templateLoaded', function (path) {
        $('#tabOne').bind("click", function () {
                        screen.showTab("TabOne");
                    });
                });
SharK
  • 2,155
  • 1
  • 20
  • 28
  • Whilst you're attempting to change the tab in a js script, are you using the LightSwitch HTML client or the Silverlight Desktop/Web client for the screen showing the tab control? – Chris Cook Jul 07 '16 at 14:15
  • @ChrisCook, thanks for your reply. I am using LightSwitch HTML client (default.htm) – SharK Jul 07 '16 at 14:43
  • Am I correct in assuming that the element with the id tabOne isn't a LightSwitch control and you want its selection to be mirrored on the LightSwitch screen i.e. clicking on #tabOne changes the LightSwitch screen to show TabOne? – Chris Cook Jul 07 '16 at 20:55
  • Chris, It is a LightSwitch control and I have created a hyper link to call the tab. Pl. let me know if you need more information. – SharK Jul 08 '16 at 04:14
  • I've added an answer containing some pointers for calling a LightSwitch screen's showTab method. If this doesn't provide the details you need, please can you organise a wider code example. Also, when you refer to .lsml.cs in your question, do you really mean .lsml.js (i.e. the JavaScript code related to a HTMLClient screen)? – Chris Cook Jul 09 '16 at 21:24

1 Answers1

1

As covered in the following SO post, normally you would programmatically change the current tab on a LightSwitch screen by using the showTab method available from the LightSwitch screen object:

LightSwitch Tabbed screen in Browse template

This LightSwitch screen object is passed into most of the standard LightSwitch methods including the screen's created routine and any button execute methods.

However, if the LightSwitch screen object isn't available at the point you need to execute the showTab, you can still access the method by instantiating an ad hoc screen instance and then calling its showTab method as follows:

$("#tabOne").bind("click", function () {
    var screen = new msls.Screen();
    screen.showTab("TabOne");
});

The reason the ad hoc screen instance can be used is that the showTab method ultimately addresses the currently active LightSwitch screen.

Community
  • 1
  • 1
Chris Cook
  • 2,821
  • 1
  • 20
  • 32