DevExpress - How to detect the device we are running on

1.1k views Asked by At

I have downloaded the Devextreme package installed it and created a project in VS using their template.

I have created a simple 'hello world' dxview using iPad dimensions and one using iPhone dimensions.

Now I wish to load the correct view during first load, something like this:

if (runningOnTablet)  <-- THIS IS THE QUESTION!
   DevExtremeIPad.app.router.register(":view/:id", { view: "pgIPad", id: undefined });
else
   DevExtremeIPad.app.router.register(":view/:id", { view: "pgIPhone", id: undefined });

How do I go about writing views that look good on an iPad vs iPhone using the same code base (viewmodels etc)

I have created other sample views that look good on iPhone and therefore also on Android but if the user uses a tablet I wish to present different views!

Thanks

2

There are 2 answers

2
Alex Skorkin On BEST ANSWER

Use the devices object, e.g.:

var defaultView = DevExpress.devices.current().tablet ? "pgIPad" : "pgIPhone";
DevExtremeIPad.app.router.register(":view/:id", { view: defaultView , id: undefined });
0
rChavz On

alternative method

if you have index.js in your project, look for something like that

var device = DevExpress.devices.current();
alert(device.platform) ;