0

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

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Marcel
  • 2,148
  • 6
  • 31
  • 48

2 Answers2

0

Use the devices object, e.g.:

var defaultView = DevExpress.devices.current().tablet ? "pgIPad" : "pgIPhone";
DevExtremeIPad.app.router.register(":view/:id", { view: defaultView , id: undefined });
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
  • Fab - that's what I was after! Is what I am doing the correct thing? I mean, depending on the device using different views? Can't see an example from DevExpress regarding this... – Marcel Sep 03 '13 at 12:48
  • It depends on the content posted in your views. Some views can be universal, like the login view with a couple of fields, some not. If a view has a large content, it is absolutely fine to make it tablet-specific. – Alex Skorkin Sep 03 '13 at 13:55
0

alternative method

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

var device = DevExpress.devices.current();
alert(device.platform) ;
rChavz
  • 235
  • 3
  • 16