Search code examples
javascriptvisual-studio-lightswitchlightswitch-2013

Lightswitch HTML - Table filter where not null


When you create a browse screen and add a table control on, you can filter it down to find specific's, however eliminating null values is not one of the basic options, please could someone point me in the direction of how I can achieve this or if this even possible?

Example: enter image description here

When the "EstTravelFromSite" is null, I would like the table not to show this result.

can I achieve this on this screen or by entering some JS code on the table?

Thankyou for any help


Solution

  • Lightswitch will give you the options "is null" or "is not null" if the column you're filtering on is a nullable datatype. If you're using the Lightswitch table designer to create your data models, Lightswitch will expose any column which isn't marked Required as a nullable data type (oversimplification but sufficient here). So check your data definitions.

    Table designer showing required and not required (implicitly nullable) integer properties. Table designer showing required and not required (implicitly nullable) integer properties

    Screen query filter for a nullable property Screen query filter for a nullable property

    Screen query filter for a required property Screen query filter for a required property

    The other alternative if that won't work in your design is to create a query (right click on the table and select Add Query) then add code to filter out records with nulls (Write Code -> Query1_PreProcessQuery). Because this is happening on the server side, the code will be VB or c# depending on how your project was created. Then use the query rather than the table as the source for the screen.