Saturday 19 July 2014

Filtered Query in LightSwitch Htmlclient.

While working in LightSwitch Htmlclient, some times we need to apply filters on Screen. e.g we want to filter data according to Customer ID, Some time want to filter data according to Customer Name and so on. In the following paragraphs I am going to discuss how can we apply various filter queries.

Integer Filter Query:

var datatype = ":Int32";

var filter = "(Customer/ID eq " + msls._toODataString(contentItem.screen.ID, datatype) + ")";
    myapp.activeDataWorkspace.ApplicationData.TableName.filter(filter).execute().then(function (QueryResult) {
        if(QueryResult.results.length<= 0 )
        {
            // Write code here.

        }
    });


String Filter Query:

var filter = "(Email eq " + msls._toODataString(screen.Email, ":String")
             + ") and (PSSWD eq " + msls._toODataString(screen.PSSWD, ":String") + ")"; myapp.activeDataWorkspace.ApplicationData.TableName.filter(filter).execute().then(function (result) {
      
              // Write code here.
       
    });