Umbraco, how to add onChange functionality on dropdown content backoffice? - umbraco

I am having one document type which contains a dropdown list, I need to add a couple of things in it:
I need to display the Database table names in drop-down dynamically.
On the change of dropdown option, i need to display the selected table columns names in another drop-down.
Are above things possible by using only existing data types or it will require creating a custom template using razor syntaxes (if it is so then how the template will display directly in the back office content node?)
Can you please provide your views and any links for code/tutorials?
screen shot of content form

If this is for the back office, you will need to do it in HTML and Angular, with an API controller to handle the DB lookup stuff.
As far as I'm aware, there's nothing built in to do dropdowns that depend on each other, so you'd have to create a new DataType to do it.
The process is to long to detail here, but here are some useful links on creating custom DocTypes in Umbraco 7.
https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/
http://velstand.info/tips/umbraco/to-create-a-datatype-by-using-external-data-sources/
https://24days.in/umbraco-cms/2016/custom-property-editor-tutorial/

Related

Laravel Nova custom field vs. resource tool vs. action for something like the Google Drive Picker?

At this early stage of Nova development (and w/ my limited overall experience), I'm having a hard time figuring out when each customization type should be used. In this case...
I have a "Customer" resource, and each customer has a google_drive_folder_id. While in index view, I'd like to click a button on the customer record item and open a Google Drive Picker for the customer (passing the customer's folder ID to the picker).
How is this type of thing best implemented within Nova? Here's what I've considered:
Custom Field - I can create a "DrivePicker" field type which displays as a button within the index view. All of the Javascript is housed within the custom field code, so it can display the picker on click. But it seems silly to create an entire custom field component when no data is stored in the field and it's only displayed within the index view.
Computed HTML Field - As of v1.0.9, you can display computed fields as HTML, so I could potentially create an html link to display the picker. But where does the picker's Javascript go?
Resource Tool - It seems like the drive picker is a tool tied to a resource, but there's not really anything for me to display - just a button that triggers the picker. I don't see how I could display the button without having to go into the resource detail screen either.
Action - "DisplayCustomerDrivePicker" seems like it might be a logical action. However, checking the customer and using the dropdown menu is tedious, it would fall apart if multiple customers were selected, and there's no actual backend action to perform - so I'm not sure this is even possible.
Any guidance would be appreciated. This is one example, but I find myself frequently relying on custom fields that hold no data, and it just doesn't feel right. Usually, it's when I want to display a modal with some resource details without leaving the index view.

getting mvc index and details for to display an actual value vs an ID value?

yeah the question is: can mcv display on the details and index form the text data values vs just ID value that gets stored in the database .
It seems that mvc is very limited in what it can display to the screen. All of the demos and tutorials seem to stop short of showing this is a possibility most just show the user typing in the the full text value. So for example the user has a user interface form that has a list of values drop down element. THey click the value and the ID gets stored to the database.
Later on recall the user wants to pull the data back up for review... in mvc it seems you are stuck with displaying the ID field in the textbox.
but in most other systems you can make a datatable and return the text value of the field back to the form... Is this possible with MVC or are you limited to saving the full text value to the the database?
enter image description here
enter image description here
yeah the answer is: Make a view in SQL Server and then Link that View to the application via the EDMX. Details below.
Finally! I was able to figure out and I will post the solution so that it may help some one get around the mvc / normalized database limitation that seems to exist when you try to follow some of the tutorials.
The key is to build a SQL view outside of MVC. This can then be linked to the application and it will appear to be a table.
So if you use the database first method and you are using SQL server you will need to simply make a view in SQL server. This take mvcs out of the picture all and is much easier.
Step 1: Make a SQL view... that has everything you need joined in one big super view for what you need to display.
So in my case I made a sql server view that has the storage table linked to the support tables. Think of the query builder in MS Access where you link your tables to make a query.
You draw out your tables and links.
Add that to your Database First EDMX and in your controller use that new super view... and in your index and details forms you change the #model to your new super sql view and change the field name in the textboxfor... Boom problem solved... pretty swell how it all works... in this way you don't have to build some complicated view model. You just take the class that the wizard builds and then make a partial class to rename fields to give them user friendly names.
And you are no longer limited by mvc limitations
hope this helps!

Partial Page Postback'ish MVC 4

First, I apologize if this is a dumb question, but I'm new to MVC and am trying to get up to speed as quickly as possible. I have spent hours searching for answers and even went and bought a book on MVC 4, but it still didn't answer my question.
I have a form I'd like a user to fill out to add a new product to the catalog. They choose the category, enter the name, a description, etc.. On the same page I'd like them to be able to add sizes or product options such as Small, Medium, Large, etc.. The problem is I'm not sure how to go about this.
I need to temporarily store the size options for example in some sort of collection until the user actually 'saves' the product, then I need to be able to read the collection. What I'm trying to avoid is to have the user add the basic product info, then save it, then select it, then choose to add options to it. I'm trying to just do it all on one form. Any help would be greatly appreciated!
There is nothing preventing you creating a view model with its own collections for the detail items and have those mapped to some sort of javascript control for selecting multiple items such as one that writes to an mvc hidden form control.
The controller handling the postback will simply create the master model from the postback data (the updated view model) and then create the child records. The whole thing could be achieved with ajax calling a controller action that returns a partial view of the updated ui.
Similar to this but have the list as a property of the master model
http://www.stevefenton.co.uk/Content/Blog/Date/201002/Blog/How-To-Handle-Multiple-Select-Lists-In-ASP-NET-MVC/
A little more advanced on how to manage your own bindings http://www.dotnetcurry.com/ShowArticle.aspx?ID=584
Sounds like u need to roll your sleeves up and get a control written in javascript that allows child items to be added client side whist serializing e.g. Into json when they save and saving it to an mvc hidden control ready for postback. Use json.net to hydrate these values into your pocos. http://erraticdev.blogspot.co.uk/2010/12/sending-complex-json-objects-to-aspnet.html

Create a View of type List in ASP.NET MVC 2

I am practicing MVC 2 (I'll do MVC 4 in just a bit) after almost 2 years, just to revise before I jump to MVC 4.
I am creating a strongly typed view of one of my data objects called Category. I want to create a list type view, i.e. a view that displays all records from the Category table.
I recall there used to be T4 templates of each type of view -- Index, List, Create, etc. that you could choose from.
But I can't find them. When I create the View, the Add View dialog shows a disabled input field for View content.
I don't think you can have Visual Studio generate the list for you. After all, you need some lookup logic to get all the objects you want to display in the list.
You might want to check out this blog post for a nice way to pass a list of objects into your drop down list. You will, however, need to supply the objects yourself.

MVC selectable GridView

I am designing a webpage using MVC. One of the pages has the following controls and functions:
Controls:
2 GridViews (gvItems, gvSelectedItems)
3 buttons (btnTransferSingle, btnTransferAll, submit)
Functions
gvItems will be populated with a set of items that contains: Name, points
gvSelectedItems will contain items that is transferred from gvItems. Hence it will also contain: Name, points
both GirdViews supports multiple selection
btnTransferSingle will transfer all selected items from gvItems to gvSelectedItems.
btnTransferAll will transfer all remaining items from gvItems to gvSelectedItems.
btnSubmit will send all the items from gvSelectedItems to the Controller.
I am not sure how to the following:
1) How to create a gridview that supports multiselection and displaying of multiple model attribute.
2) How to transfer the items from one gridview (gvItems) to another (gvSelectedItems)?
3) How to pass back all the items from gvSelectedItems to the controller?
I am able to do the stuff that was mentioned using listBox but listBox only allows displaying of only one attribute and doesn't have a header.
I used Matt Kruse Javascript's Toolbox to aid the moving of items between listboxes.
Any help is appreciated. Thanks.
I think that listboxes are the correct approach here.
If you want to display both attributes try to concatenate them when loading the data.
Headers can be somewhat added with html/css

Resources