Display views in browser or mobile native

Hi guys,

The CONTEXT("Host") does not work for me, what am I doing wrong?

I have these two views, it's the same table of course, only the idea is that the app only shows 3 fields, and the broser shows all the fields

Customers table first View "CustomersApps" type table, column order (3 fields) Show if = CONTEXT("Host") = "Device"

Customers table second View "CustomersBrowser" table type, Column order (all) Show if= CONTEXT("Host") = "Browser"

However, both are shown both in the app and in the browser, that is, it does not work

Greetings

LeviP_0-1686002910009.pngLeviP_1-1686002953801.png

 

Solved Solved
0 22 1,161
1 ACCEPTED SOLUTION


@LeviP wrote:

I have a submenu table and the View type is gallery

When you have a gallery view, the items displayed are not VIEWS and therefore will not use the View Show_If property to determine visibility.  They are simply rows from whatever table you are using as the source.  Your rows may correlate to some view meta data such that when the gallery item is clicked your are redirecting the user to a specific view through an action.  In this situation, you would need to use a different mechanism to show/hide the gallery items based on Host context.  I said to use Show_if in the column which was wrong.  Instead you would need to filter the rows with a Slice and use that Slice as the data


@LeviP wrote:

and the idea of showing two views to the same table is because for the desktop version all the columns can be added, while for phones only about 3 columns


I don't understand what this means

 

source for your Gallery Submenu View

View solution in original post

22 REPLIES 22


@LeviP wrote:

The CONTEXT("Host") does not work for me, what am I doing wrong?


The parameter passed IS case-sensative, I believe.  Try using "Host" and not "HOST".

Also note that when testing in the Emulator it is ALWAYS treated as "Browser" (its a web page!) - even if testing the mobile form factor.   So to accurately test "Device" related logic you will need to perform the tests on an actual mobile device.

 

Hello Thank you
Try using "Host? Not not working

testing in the Emulator! No, I already tried with different devices with other normal users of use
it still doesn't work

Ok.   Maybe try = "Browser"  and <> "Browser"??

Also, Taking a closer look, the views you are referencing are "Reference Views".  These do not show by themselves.  Where is it that you are trying to show these?  Maybe in a Dashboard view?  Please provide us more details of what you've implemented and the actual displayed result so we can understand more clearly.

Point is that the expressions you have implemented should work fine with "Host" as parameter.  Something else is causing issues.

I am not sure what is happening, this my view

LeviP_0-1686082446050.png

LeviP_1-1686082517177.png

 

 

Hi there, it does case-sensitive.

I do have a youtube video that shares how to apply the CONTEXT(), hope it helps:

https://www.youtube.com/watch?v=sOqnwEj2VuI

Thank you, I had already seen this video like 5 times

did you ever find an answer?  It's not working for me as well.  I've tried everything including all the case sensitive recommendations, but it just does not work.

Someone please help!  I have an app that I only want to be accessible via browser.

Then I belive your script is something like this:

CONTEXT("HOST")="BROWSER"

???


@rgrantz123 wrote:

I've tried everything including all the case sensitive recommendations, but it just does not work.


I'm late responding ...ben on vacation for the past 2 weeks.  If you are still having issues with this, Please provide details to show what is not working for you.

For a view to display ONLY in the Browser. it should be as simple as adding the View's "Show If" property (under the Display section of the view) the following expression:

CONTEXT("Host") = "Browser"

Note: That the AppSheet Emulator of a mobile device IS in the Browser so views defined to display only the Browser will also show in the Emulator.  To properly test that the view does NOT show, you will need to run the app on a phone or tablet but be aware that depending on how you access the app on these mobile devices, you could be running them in Browser mode as well.  The best way to ensure you are testing the native app version is to download the AppSheet app on the mobile device and use the App Gallery to launch your app.

 

Thanks for the help,

I could see why it doesn't work, this parameter doesn't work for Ref positions, and the views of my menus are as icons in the REF position

See that the views with the positions in REF do not work, they are the ones that are marked with a yellow X, however the others themselves work
So how to make this command work in the REF position

LeviP_1-1693245587355.png

 

 



REF View is not reachable by app user, between, how this REF view is run? from an Action?

The app emulator in the AppSheet editor will count as a browser as long as it is in the browser. Try it on your smartphone and it will work.

Hi Peterson, it does work, but it only works for views that are PRIMARY NAVIGATION or MENU NAVIGATION, but for REFERENCE VIEWS, which are the ones I use, as well as the images in the center of the screen, it doesn't work there

It should be the same and work, but it doesn't

In the previous photo there are two devices, a browser and smartphone, in both it works only if the view is in PRIMARY NAVIGATION or MENU NAVIGATION, but if you see the photos there are some X marks, it does not work there since they are referenced views

The Submenu view you're showing that has the Yellow X's, how is it defined??

Because to me it looks it is a Gallery View of which there are row items labeled as "ClientesBrowser" and "ClientesApp".  If that is the case then these row items are NOT filtered by the Show If constraint on the views.  They can be filtered by using the Show If property on the proper column of the Table your Gallery View is based on.

Hello,  Yellow X's, how is it defined??

I have a submenu table and the View type is gallery

and the idea of showing two views to the same table is because for the desktop version all the columns can be added, while for phones only about 3 columns

The point is... Usually the ref views are the same as primary views. 
Have you tried the Inline views? maybe this is the issue you're looking for.

in case it does not work, please send a screenshot of teh exact views you're trying to manage. Not the app editor itself, but the app view, so that I can better understand what you mean.

Actually what I want is to show all the fields of the table when the view is for desktop, and only three columns when it is for smartphone


@LeviP wrote:

I have a submenu table and the View type is gallery

When you have a gallery view, the items displayed are not VIEWS and therefore will not use the View Show_If property to determine visibility.  They are simply rows from whatever table you are using as the source.  Your rows may correlate to some view meta data such that when the gallery item is clicked your are redirecting the user to a specific view through an action.  In this situation, you would need to use a different mechanism to show/hide the gallery items based on Host context.  I said to use Show_if in the column which was wrong.  Instead you would need to filter the rows with a Slice and use that Slice as the data


@LeviP wrote:

and the idea of showing two views to the same table is because for the desktop version all the columns can be added, while for phones only about 3 columns


I don't understand what this means

 

source for your Gallery Submenu View

Thank you, i undertand you


@WillowMobileSys wrote:

I don't understand what this means


I mean that I create two views with the same table, one view only have 3 columns for smartphone, and the other have all columns for desktop, but now i understand you

Now the question I have is how can I display certain records in CONTEXT()

 

Thank you all for your collaboration, I have already solved it, as this type of view is by record, so I applied the CONTEXT() function in a slice filter, and problem solved

Thank you


@LeviP wrote:

CONTEXT() function in a slice filter, and problem solved


Yes!   That is the way to solve it.  Glad you were able to resolve it!

 

Top Labels in this Space