Hide the Save/Cancel/Ok/Discard buttons in a LightSwitch HTML screen.

Today I’m going to hide the Save/Cancel/OK/Discard buttons in a LightSwitch HTML screen.  Why? Because it’s really cool.

On any screen, select the “Write code” button and find the “activated” event (I’m sure this is still on the planning, but the CTP4, which is the current version, only has a “created” event; However you can tap into the post_render method of the last control on your screen as a workaround) and type:

 

myapp.Home.SomeControlInMyHomeScreen_postRender = function (element, contentItem) {
    $("[data-ls-tap='tap:{data.shell.discardCommand.command}']").hide();
    $("[data-ls-tap='tap:{data.shell.saveCommand.command}']").hide();
    $("[data-ls-tap='tap:{data.shell.okCommand.command}']").hide();
    $("[data-ls-tap='tap:{data.shell.cancelCommand.command}']").hide();
};

The code uses a simple JQuery selector to find whatever HTML element has been rendered with a discard, save, ok or cancel command “attached to it” (the LightSwitch way), then uses the JQuery hide() method.

Bam, just like that. 

The code shows some interesting details about the way the LightSwitch HTML client attaches commands to an HTML element, once I understand any of it I’ll make sure to share :-)

 

Keep rocking LS!

About these ads

4 thoughts on “Hide the Save/Cancel/Ok/Discard buttons in a LightSwitch HTML screen.

  1. Pingback: LightSwitch Community & Content Rollup–March 2013 - Beth Massi - Sharing the goodness - Site Home - MSDN Blogs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s