문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top