顯示具有 LightSwitch 標籤的文章。 顯示所有文章
顯示具有 LightSwitch 標籤的文章。 顯示所有文章

2014年4月15日 星期二

LightSwitch – ThemeRoller, Visual Studio 2013

ThemeRoller, change UI

Current project is using light-theme, we want to change their color by jQuery Mobile ThemeRoller

1. Open css file, light-theme-2.0.0.css

2. Select all content

3. Copy all content

image

 

Go to URL: http://themeroller.jquerymobile.com/

1. Click Import button on the top

2. Choose right version of jQuery mobile (see above Visual Studio Solution Explorer, it shows 1.3.0)

3. Paste css content copied from previous step

image

 

Just drag & drop the color to the place which you want to change its color

image

 

1. Click Download, it will show Download Theme screen

2. Input a Theme Name by yourself

3. Click Download Zip button

image

 

Back to Visual Studio, create a new Style Sheet file, custom-theme.css

SNAGHTML1682afd

 

1. Open the downloaded zip file

2. Select all and copy them

image

 

Paste into custom-theme.css file

image

 

Change the link of default.htm, from “light-theme-2.0.0.css” to “custom-theme.css”

image

 

Run it to see the result

SNAGHTML174592e

LightSwitch – Custom Code on HTMLClient, Visual Studio 2013

Custom Code on HTMLClient

There are 4 types allow us to write custom code

image

 

No worry, LightSwitch has loaded following libraries for us

image

 

Example 1: Add default value of input field, Address1

Write code on created method of field Address1

image

 

Input following code in .lsml.js file, assign default value if Address1 is empty

image

 

The result is like below

image

 

Example 2: Show image/picture on screen

1. Click button, Add Data Item

2. Choose Local Property (can leave default Type = String)

3. Name it, Logo, as example

image

 

1. Drag & drop Logo into the place that you want to display

2. Change its Type to Custom Control

image

 

Write code within Logo_render method

image

 

Append <img> tag and given correct src attribute

image

 

The result is like below

image

2014年4月14日 星期一

LightSwitch – Custom Code, Visual Studio 2013

 

Custom Code

Custom Code on ApplicationData in Server Side

 

1. Add a new field, Disable in Customers table

2. Choose Write Code to show out event trigger of Customers table

3. Choose Customers_Validate method

image

 

1. We can get original value of a field before user made change, by entity.Details.Properties.fieldName.OriginalValue

2. results.AddEntityError() to add a validation error

image

 

1. Validation Error pop up if Disable is originally equal to True and user want to change the record.

2. It won’t show if user just change Disable from False to True and then save the record.

image

2014年4月8日 星期二

LightSwitch – Access Control, Visual Studio 2013

Access Control

2 access controls for LightSwitch, Authentication type and Permissions.

image

 

Authentication Types

There are 2 authentication types, Windows & Forms.

In this example, we use Forms authentication.

image

 

Permissions

Add 4 permissions for practice, CanAddCustomer, CanEditCustomer, CanViewCustomer and CanAddPhone

Granted for debug is a flag to allow developer to run/execute while programming

image

 

We can write code on Access Control Methods of an ApplicationData, for example, Customers.

image

 

Check if current user has pre-defined permission (CanAddCustomer) on customer insert action

image

 

It will show an Error if user does not have that permission

SNAGHTML1db84b2

2014年4月7日 星期一

LightSwitch – Query, Visual Studio 2013

 

http://msdn.microsoft.com/en-us/vstudio/gg604823

http://blogs.msdn.com/b/lightswitch/archive/2013/11/07/new-navigation-features-in-lightswitch-html-client-chris-rummel-rohit-agrawal.aspx

http://msdn.microsoft.com/en-us/library/ee256728(v=vs.120).aspx

Query

http://blogs.msdn.com/b/msdntaiwan/archive/2014/04/01/vs2013-lightswitch-4.aspx

1) Add Query from Application Data

4. Change parameters to become Optional

image

Following are two query example for different Application Data

image

 

2) Browse Screen

Instead of create a new Browse Screen, we can just change the original one on its Query Source to new added query.

image

Drag & drop 2 parameters to layout and change their Control Type to Date Picker

image

The result is like below:

image

 

3) Add Query from Application Data, but search UPPER level table

1. We can add a group of filter like 4 which is query on upper level table (Customer, system enable for us by default) 2. We can also use only one parameter (FindString, in the example) to query on different fields of Cutomer and Phone tables

image

 

4) Browse Screen

Add another brwose screen base on new query added above, SearchByNameOrPhone

image

Results are like below:

SNAGHTML75bba3

Query by Phone:

SNAGHTML76b491

Query by Name:

SNAGHTML772991

 

5) Screen Navigation

1. Right click on HTMLClient of Solution Explorer –> Click Edit Screen Navigation

2. Add two browse screens in Screen Navigation menu

image

The result is like

SNAGHTML8317e5

LightSwitch – Screen, Visual Studio 2013

Screens

http://blogs.msdn.com/b/msdntaiwan/archive/2014/04/01/vs2013-lightswitch-3.aspx

1) Search

image_thumb[30]

BrowseCustomers – Edit Query

image_thumb[16]

Edit Query – Filter, Sort, Parameters

image_thumb[14]

Drag & drop parameter FindName and change to TextBox

image_thumb[20]

 

 

2) Add Customer Button

SNAGHTML15ec586_thumb[2]

Command Bar –> Add

image_thumb[26]

No need to tick Email & Phone

SNAGHTML161ff8a_thumb[3]

 

3) View Detail Screen

SNAGHTML16ae4f8_thumb[3]

Action – Item Tap

image_thumb[29]

Also show Email & Phone on the screen

SNAGHTML1686a9b_thumb[2]

 

4) Add “Edit Customer” Button

image_thumb[33]image_thumb[35]

SNAGHTML1729016_thumb[3]

 

5) Show Email & Phone as Title List

Move Email & Phone to under Customer Detail Tab, change to become Title List layout and check Show Header

Before After
image_thumb[43] image_thumb[44]

SNAGHTML17c3b33_thumb[4]

 

6) Add “Add Email” & “Add Phone” buttons

image_thumb[47]

SNAGHTML180b9f3_thumb[3]

 

7) Delete Customer field on Add Email and Add Phone screens

image_thumb[50]

SNAGHTML18ec1df_thumb[2]