Thursday 19 December 2013

Change Event in LightSwitch HtmlClient

Change Event in LightSwitch HtmlClient?

While Developing an application in Lightswitch HtmlClient I faced a problem that how can we get the price of selected Product when a sales person sales an item. We can do this thing on change event of the product selection. But in Lightswitch HtmlClient Application we can call the change event with the help of addChangeListener function. Following are the steps to resolve this problem.


 How to fetch the Price of selected Product in text field.


Step 1: write the following code on the Created event of the current screen.

myapp.AddEdittbOrderLineItem.created = function (screen) {
    // Write code here.
    screen.tbOrderLineItem.addChangeListener("tbProduct", function (e) {
        var contentItem = screen.findContentItem("tbProduct");
        screen.tbOrderLineItem.ProductPrice = contentItem.details.value.Price;

Result: Now you are able to get the selected Product price.