0 votes
713 views
in Coach Views by (21.5k points)

1 Answer

0 votes
ago by (30.6k points)

The Device Sensor control reports the device / browser type and screen size to your coach so that layout and behaviour can adapt (responsive rules beyond CSS). It renders nothing; its value is a bound object / options you read in code.

  • Read it with the control API: the sensor exposes methods such as isMobile(), isTablet(), isDesktop(), getScreenSize() (XS / SM / MD / LG in Bootstrap terms) and fires an event when the size class changes (On change / on resize).
// coach load or the Device Sensor's "On change" event
var d = ${Sensor};
if (d.isMobile()) {
  ${Table}.setVisible(false); ${CardList}.setVisible(true);      // cards instead of a wide table
  ${Sidebar}.setVisible(false);
} else {
  ${Table}.setVisible(true); ${CardList}.setVisible(false);
}
console.log("size class:", d.getScreenSize());                    // "xs", "sm", "md", "lg" 

Typical uses: choose between a table and a card layout, collapse navigation on phones, hide help text on small screens, change page sizes, and pick the camera-based File Uploader options on mobile. Combine with the responsive settings of the layout controls (Horizontal Layout's Responsive columns, per-screen-size widths) which need no code; use the sensor for logic, not for plain layout.

References

Related questions

0 votes
1 answer 1.1k views
0 votes
1 answer 1.3k views
0 votes
1 answer 1.3k views
0 votes
1 answer 847 views
0 votes
1 answer 704 views
0 votes
1 answer 893 views
0 votes
1 answer 2.4k views
0 votes
1 answer 2.5k views
0 votes
1 answer 785 views
0 votes
2 answers 3.1k views
0 votes
1 answer 1.4k views
0 votes
1 answer 526 views
0 votes
1 answer 2.0k views
0 votes
1 answer 1.5k views
0 votes
1 answer 1.7k views
0 votes
1 answer 4.0k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...