Question

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

Was it helpful?

Solution

Use the devices object, e.g.:

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

OTHER TIPS

alternative method

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

var device = DevExpress.devices.current();
alert(device.platform) ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top