Create Sub Menu Links In Navigation And On Demand Pages

Is there a way to create sub menus under Links for a dashboard type setup?

Was also hoping maybe there was a way to create pages on the fly from say records in a DB so each snake could have its own page that is a template that pulls from the DB record and populates the name, etc. Is something like this possible?

I’ve had fair success using a Grid Panel for hierarchical menus. Up to 12 levels of indentation are available this way.

Just be sure that you always build your hierarchies from the top down. That is, your code can easily append items to the Grid Panel – append a (named) row, append a (positioned) item within a row, left-to-right – but it can’t insert items.

Rows can be deleted, hidden, and un-hidden. If you do the latter two, then you’ll want to set vertical spacing (of the hideable item) to None. Hiding an item does not hide its spacing.

What you’re describing sounds like you have a form template that gets filled in from DB data? Or can the form itself change based on the particular data in the database? The first is pretty easy.

A form that is filled in from record from the db would work with a separate page/form for say each snake record in the db

You can instantiate your form with the DB record, e.g.

bobby = Form1(snake=app_tables.snakes.get(name='bobby'))
open_form(bobby)

Here’s an example app that does that

https://anvil.works/ide#clone:TGA32CW5Z4DHBV63=YCFUGPUSGQTQUEV274UQN7O5

2 Likes

awesome that is exactly what I wanted, thanks!

So stupid question then how would I or could I make the button/nav link have the name from the db object? Is that even possible? Otherwise my thinking was in my table object the name would just be a link maybe to a form page that gets updated with the values of whatever snake object you clicked in the table if that makes sense.

The way I would use your example right now would most likely just be put a button in the table to say more info or something and when they click that it opens up the snakes page with more information about it like the picture, feeding etc, but my main curiousity is how to make this a real nav page in my menu on the left which would be created on demand from the snakes found in their part of the db table if that makes sense.

Let me know if I need to clarify any of that.

Also @shaun any idea how to use the similiar content.panel option with clear and add to make this look more seamless? Right now when I click a link from my table to open the individual snake page that works but atm its just using a blank page since I don’t have the option to use content_panel to make it fit with the dashboard theme, any idea on that?

so you can see what I have so far

com-resize

So I got it working by using:

form_indv_snake = IndividualSnake(snake=app_tables.snakes.get(name=self.item['name']))
get_open_form().content_panel.clear()
get_open_form().content_panel.add_component(form_indv_snake)

This is slick now I have pages I can get to from the table link’s then I can just have this be a template page laid out the way I want it with dashboards etc that get populated from the table data.

nerdy_python

Thanks again!

Looks nice, good to see you’ve got it working. The logo on the front page is great!

Yea thanks I’m really liking it, now if I can figure out how to do nested menus people can click on I’ll be golden. I just have to build out the template pages now but I think this site is gonna be great

Really liking the product

I found your previous post in another thread with the help, it helped a lot!

I"m trying to work on this now, do you have any examples showing how to do the add_components so that the links show up together under each other for certain menus? Like a top level Snakes menu with Add Snake, Delete Snake, etc that show up when you click it, etc.

If the “Snakes” menu is added with col_xs=N, then add the immediate sub-items with col_xs=N+1.

Yea I got it working following your other example, now I’m setting up the mobile piece so that when they click on a top menu item it doesn’t hide the menu, only until they click a sub menu item will it close the nav.

Your other thread was easy to follow and made it easy to setup.