SA_controls - treviewitem

Hi,

in the Citect help, there is mention of the treeviewitem to support navigation of pages.

"The Tree View Genie (named "treeview") can be used to display a menu structure on a page. For example, you can use it to:

  • Display an equipment hierarchy
  • Filter an alarm page
  • Navigate pages
  • Display alarm counts"

if that's the case, does anyone know how to set it up for page navigation? it needs to show the alarm levels too (no checkboxes required)

the datasource can be used to point to the navigation (but what is the menu item?) is it Navigation?

are we able to achieve the same functionality using the treeview as per the default PageNavigation_1TabRow_HD1080 ( sa dashboard?)

How should we configure the tree view genie ?

Parents
  • Hi Ignatious,

    To bind it against the Navigation menu, set the Dataource parameter of the tree genie to "Navigation" (no quotes) and add a left click handler.

    The left click handler should be:

    FUNCTION MenuTree_OnClick(INT hMenuItem)
    _Navigation_RunCommandFromMenuHandle(hMenuItem, TRUE);
    END

    This will allow you to preserve navigation stack behaviour.

    When you run that up you'll notice it all works - except for when a navigation occurs from something like a contextual change navigation e.g. navigate to equipment from an alarm on an alarm page.

    To get that working, you need to add a cicode animation object to the pagethat contains your tree control. Make it class a function: MenuTree_SyncSelection.

    The code of which is below.

    Note: This is all from a workspace customisation topic I've been putting together so it has not gone through formal testing.

    FUNCTION MenuTree_SyncSelection()
    STRING sContext, sStartupContext;
    STRING sCachedPrimaryPage;
    STRING sCurrentPrimaryPage;
    STRING sNavigationPath;
    INT hMenuItem;


    INT nWinCurr = WinNumber();
    INT nTreeviewAN = DspGetAnFromName("Treeview");

    // Check if the current page has changed from the cached page
    sCachedPrimaryPage = PageGetStr(g_sCachedPrimaryDisplayPage, nWinCurr);
    sCurrentPrimaryPage = PageGetStr(g_sPrimaryDisplayPage, Workspace_GetWindow());

    IF (sCachedPrimaryPage = sCurrentPrimaryPage) THEN
    // It hasn't changed, so leave selection as is
    RETURN;
    END

    // Update the cache with the new current page
    PageSetStr(g_sCachedPrimaryDisplayPage, sCurrentPrimaryPage, nWinCurr);

    IF (sCurrentPrimaryPage <> "") THEN
    // Find the menu item corresponding to the current page
    hMenuItem = _Navigation_FindMenuItem(sCurrentPrimaryPage);
    IF (hMenuItem <> BAD_HANDLE) THEN
    sNavigationPath = _Menutree_GetNavigationPath(hMenuItem);
    Treeview_Locate(nTreeviewAN, sNavigationPath);
    END
    END
    END


    PRIVATE
    STRING
    FUNCTION _Menutree_GetNavigationPath(INT hMenuHandle)
    STRING sMenuName;
    STRING sMenuPath;
    INT hMenuItem = hMenuHandle;

    WHILE (hMenuItem <> BAD_HANDLE) DO
    sMenuName = MenuNodeGetProperty(hMenuItem, 0);

    IF (sMenuName = g_sNavigation_CoreNavigationMenu OR sMenuName = g_sNavigation_HeaderBarMenu OR sMenuName = g_sNavigation_EquipmentModel) THEN
    // Don't add the root items "Navigation", "HeaderBar" or "__EquipmentModel" to the path
    hMenuItem = BAD_HANDLE;
    ELSE
    // Add the item to the path
    IF (sMenuPath <> "") THEN
    sMenuPath = sMenuName + "." + sMenuPath;
    ELSE
    sMenuPath = sMenuName;
    END

    // Move to parent item
    hMenuItem = MenuGetParent(hMenuItem);
    END
    END

    RETURN sMenuPath;
    END
Reply
  • Hi Ignatious,

    To bind it against the Navigation menu, set the Dataource parameter of the tree genie to "Navigation" (no quotes) and add a left click handler.

    The left click handler should be:

    FUNCTION MenuTree_OnClick(INT hMenuItem)
    _Navigation_RunCommandFromMenuHandle(hMenuItem, TRUE);
    END

    This will allow you to preserve navigation stack behaviour.

    When you run that up you'll notice it all works - except for when a navigation occurs from something like a contextual change navigation e.g. navigate to equipment from an alarm on an alarm page.

    To get that working, you need to add a cicode animation object to the pagethat contains your tree control. Make it class a function: MenuTree_SyncSelection.

    The code of which is below.

    Note: This is all from a workspace customisation topic I've been putting together so it has not gone through formal testing.

    FUNCTION MenuTree_SyncSelection()
    STRING sContext, sStartupContext;
    STRING sCachedPrimaryPage;
    STRING sCurrentPrimaryPage;
    STRING sNavigationPath;
    INT hMenuItem;


    INT nWinCurr = WinNumber();
    INT nTreeviewAN = DspGetAnFromName("Treeview");

    // Check if the current page has changed from the cached page
    sCachedPrimaryPage = PageGetStr(g_sCachedPrimaryDisplayPage, nWinCurr);
    sCurrentPrimaryPage = PageGetStr(g_sPrimaryDisplayPage, Workspace_GetWindow());

    IF (sCachedPrimaryPage = sCurrentPrimaryPage) THEN
    // It hasn't changed, so leave selection as is
    RETURN;
    END

    // Update the cache with the new current page
    PageSetStr(g_sCachedPrimaryDisplayPage, sCurrentPrimaryPage, nWinCurr);

    IF (sCurrentPrimaryPage <> "") THEN
    // Find the menu item corresponding to the current page
    hMenuItem = _Navigation_FindMenuItem(sCurrentPrimaryPage);
    IF (hMenuItem <> BAD_HANDLE) THEN
    sNavigationPath = _Menutree_GetNavigationPath(hMenuItem);
    Treeview_Locate(nTreeviewAN, sNavigationPath);
    END
    END
    END


    PRIVATE
    STRING
    FUNCTION _Menutree_GetNavigationPath(INT hMenuHandle)
    STRING sMenuName;
    STRING sMenuPath;
    INT hMenuItem = hMenuHandle;

    WHILE (hMenuItem <> BAD_HANDLE) DO
    sMenuName = MenuNodeGetProperty(hMenuItem, 0);

    IF (sMenuName = g_sNavigation_CoreNavigationMenu OR sMenuName = g_sNavigation_HeaderBarMenu OR sMenuName = g_sNavigation_EquipmentModel) THEN
    // Don't add the root items "Navigation", "HeaderBar" or "__EquipmentModel" to the path
    hMenuItem = BAD_HANDLE;
    ELSE
    // Add the item to the path
    IF (sMenuPath <> "") THEN
    sMenuPath = sMenuName + "." + sMenuPath;
    ELSE
    sMenuPath = sMenuName;
    END

    // Move to parent item
    hMenuItem = MenuGetParent(hMenuItem);
    END
    END

    RETURN sMenuPath;
    END
Children
No Data