Grid design in Facility and ePortal - Part 3 (conditional formatting) This installment explains conditional formatting - how to make the appearance of your grid change when certain conditions are met. We can use conditional formatting to make the text and background of a cell appear change when certain circumstances apply, such as when a field in the database is equal to a particular value. You can see this in operation in the default attendance grid - cells have a different background depending on whether the student is present, late, authorised absent or unauthorised absent. This technique can be applied to the left hand column that contains the student names as well. Let's carry on using the grid we used last week.
The Conditional colouring window will appear, which is blank by default. This is where we specify our conditions, and what display settings to use when they are met. This is done as follows:
Let's say we wanted the highlight those students who are on the SEN register. Go through each stage above, making the following settings at the appropriate point:
You should end up with something like this:
Other formulasYou can let your imagination run wild as to how you can utilise this feature to highlight particular students. How about bringing back information from student events? If we had a student event called 'Detention' we could use this formula to highlight students who'd had more than 10 detentions since they started school: len(collapse(apply(Student.Events.Evdef.Code ,c , if(c='Detention',1,'')))) A bit more useful (and a bit more complicated) might be to highlight students who had had more than 10 detentions within the last year: len(collapse(apply(Student.Events.Evdef.Code,c,if(c='Detention' and getat(right(Student.Events.Datewhen,4) +mid(student.events.datewhen,3,2) +left(student.events.datewhen,2) ,applyposn) >=right(adjustdate(today(),-365),4) +mid(adjustdate(today(),-365),3,2) +left(adjustdate(today(),-365),2),1,'')))) The scenario I described here uses Student events to track phone calls home, then uses this formula to highlight students who'd already had a phone call home today: right(listmax(apply(Student.Events.Evdef.Code,c, if(c='ATTPHONE',getat(right (Student.Events.Datewhen,4) +mid(student.events.datewhen,3,2) +left(student.events.datewhen,2) +student.events.datewhen,applyposn),''))),10)=today() Multiple conditionsYou can add more than one condition in the Conditional colouring window. CMIS will check the conditions in order from top to bottom until it meets a condition that is TRUE, at which point it will apply that condition. Rather than just highlighting the students on the SEN register as we did earlier, we might want to use a different background colour for each stage. We would do this by adding three separate conditions to the list: Student.Sen.Stage.Stage.Code='S' Student.Sen.Stage.Stage.Code='P' Student.Sen.Stage.Stage.Code='A' ...setting the font and background formatting so that they are different for each one. The above example is fairly straightforward in that only one of the conditions can be true for each student. So what happens if more than one condition is true? In such cases, the formatting that gets applied will be the first one that matches. If we had two conditions... Student.Sen.Stages.Stage.Code<>'N' and Student.Sen.Stages.Stage.Code<>'' (students on the SEN register) and Student.Statistical.Fsmelig='Y' (students eligible for free school meals) ...students who were both on the the SEN register and eligible for free school meals would appear with the 'SEN' formatting, as that would be the first matching condition. What we would probably want to do in a situation like this would be to build a set of conditions that would give a different format to all possible combinations:
Visually, we'd want to give be consistent in our formatting choices to make it easy for the user to take in what the display is trying to say. So let's use the orange background to signify students on the SEN register, and a bold font to indicate those on free school meals. We'd need to following conditions: Student.Sen.Stages.Stage.Code<>'N' and Student.Sen.Stages.Stage.Code<>'' and Student.Statistical.Fsmelig='N' (orange background, italic font) Student.Sen.Stages.Stage.Code<>'N' and Student.Sen.Stages.Stage.Code<>'' and Student.Statistical.Fsmelig='Y' (orange background, bold font) Student.Sen.Stages.Stage.Code='N' or Student.Sen.Stages.Stage.Code='' and student.Statistical.Fsmelig='Y' (maroon background, bold font) We don't need to add the final condition as if none of the first three conditions are met the default formatting will apply, which is already maroon background with italic font. |