Expressions
Advanced expressions
3min
use advanced expressions docid\ popt9w3d els2zcvkirm1 to filter an array of records to display specific data and perform expression transformations over the data examples and code snippets examples and code snippets create a filtered list from an array of records we will display a list of people from the array of records, then filter them and display those that have entered a name we will display their initials as a left avatar and add a label to each list item to display whether they are registered result with advanced expressions see the full example in github advanced expression jigx title list with advanced expressions type jig list datasources people type datasource static options data \ id 1 firstname mark lastname dobrew email mark\@gmail com mobile 783432565 registered false \ id 2 firstname astra lastname courts email astra\@gmail com mobile 437874221 registered false \ id 3 firstname jane lastname doe email jane\@gmail com mobile 783432531 registered true \ id 4 firstname '' lastname '' email steve\@gmail com mobile 783432531 registered true data =@ctx datasources people\[firstname != '' and lastname != ''] item type component list item options title "=@ctx current item firstname & ' ' & @ctx current item lastname" subtitle ='phone ' & @ctx current item mobile description ='email ' & @ctx current item email style ishighlighted "=@ctx current item registered = true ? true\ false" label title "=@ctx current item registered = true ? 'registered' 'not registered'" color \ when =@ctx current item registered = true color color2 \ when =@ctx current item registered = false color color4 leftelement type avatar text "=$substring(@ctx current item firstname,0,1) & $substring(@ctx current item lastname,0,1)" define functions to run the expressions as part of advanced expressions, you can define functions that will run the expressions it can be a function for date transformations, maths calculations, or any string transformations by using functions you will have cleaner code that is easier to read divided by 10 this example shows a simple function that will divide the number from the datasource see the full code sample in github advanced expression jigx datasources number data type datasource static options data \ id 1 number 2500 children \ type component entity options children \ type component entity field options label expression to get result divided by 10 value =($b = function($l, $w){ $l / $w }; $b(@ctx datasources number data number,10);)