Pergunta

How do you detect if, when using LightSwitch, the detail page is in Add or Edit mode?

I want to change the title of the screen from AddEdit Customer to either 'Add Customer' or 'Edit Customer'.

I can get screen.detail.dispayName = "Something". i need to know how to detect if it is in Add or Edit mode.

Foi útil?

Solução

This is valid for HTML5 lightswitch -

There is Javascript namespace "msls" which encapsulates the LightSwitch JS framework to obtain the equivalent of EntityState.

The intellisense does not work so well, so if you keep getting screen.(nothing), add the following:

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

On the main event, add:

myapp.Customer.created = function (screen) {
    if (screen.Customer.details.entityState == msls.EntityState.added) {
        screen.details.displayName = "Add Customer";
    } else {
        screen.details.displayName = "Edit Customer";
   }
}

where Customer is the dataset for the AddEdit HTML5 Lightscreen page.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top