I am building an MVC 2 web app, where I want to display information about something (the parent) as well as child details which are displayed as rows (children have a many to one relationship to the parent).
I have implemented AJAX in MVC before using Ajax.BeginForm and partial views
Using this method - with minor changes for MVC 2 release.
I want to add the ability to edit child rows inline using ajax, but I would like to know how others implement this. Are there facilities in MVC that can do this?
Have a look at this post here. From what you're describing it's exactly what you need for your scenario. You can not only edit items inline but also add/remove item dynamically.
This is more of a requirement for Javascript plugin or library than ASP.NET MVC..
If you want the behaviour where you click on link and get into edit mode (like replace text with textbox) take a look at Jeditable.
Though I don't use it, I just create (for example, in a table) one row with fixed text and another with textboxes and then hide the one with textboxes and I only display it when user click on Edit link. I have
a save link in the edit row and when this is clicked I just hide the edit row. I post the data using regular form post not ajax post.
Related
I wonder if there is a pretty way of creating a dropdown, in .Net Core 2.0 MVC, where the items can be added or deleted? I have found multiple solutions for adding, but none that includes delete. Below is a mockup that illustrates how I envision it.
Clicking on the name will select it. Clicking on the red crossed box will delete the item (with underlying WCF backend delete). Clicking "Other" will show a new textbox where a new value can be entered.
You can use a jQuery plugin like Select2 that allow to delete (in tagging mode) and adding values.
There are several others jQuery plugins to chose.
I'm building a website using the ACF plugin (Version 5 Pro), and I'm setting up a button on a page template, which by itself isn't the problem. The problem is that depending on the specific content of each individual page using that template, the button can have one of several different appearances. What I'm trying to do is set things up so that I can upload all the buttons into the default value section of the ACF field ahead of time, and then every time I make a new page using that template, simply select the appropriate button from a radio button, a dropdown menu, or something similar on the backend of the page. I plan to be constantly uploading small amounts of content using this template, so not having to manually select the appropriate images on each page would save me a lot of time.
I've googled around and there wasn't a good answer I could find anywhere, so I'm hoping one of you more knowledgeable folks could help me out!
(And before anyone proposes this as a solution, no, the content of each page isn't something I can define just using programming. It's a little more abstract and needs human input. If all else fails I can just make multiple templates and simply select the appropriate one when I go to make a page, but the way I'm trying to do it now would be a lot cleaner).
You can try ACF Flexible Content:
https://www.advancedcustomfields.com/add-ons/flexible-content-field/
Using Flexible Content field, you will be able to create multiple fields (button 1, button 2, etc) including a WYSIWYG editor and build the buttons HTML adding the default value of the field.
You can read:
https://support.advancedcustomfields.com/forums/topic/html-default-values/
However, I think you'll get in trouble making your buttons dynamic with this approach... so I'd suggest it will be better if you keep some parts of the buttons (like URLs) dynamic, using an extra field to enter the URL, anchor, etc.
In Salesforce, we have a button that creates events with the fields already filled out, but after the item is created I want it to reload the screen in the "Edit" view in case they want to change anything. Any ideas?
Do you need to validate fields values? Maybe it will be easier to do with field validation rules? It can be useful in cases when your data is populated not only from user screens, but also can be created in code (classes/triggers) or via API.
If you know that you exactly should to use JavaScript, you can add standard event attributes to command buttons on your Visualforce page and write JS functions for implementation of your validation logic.
I ended up creating a visualforce page with a controller and a custom button to accomplish what I needed.
I am using ASP.NET MVC 5.
My idea is to have modal view like on the picture.
When I click on "Add" I would like to add dropdownlist with same items inside like the others before. (Dynamically adding Html helper controls) At the end when I have selected values I would like to put strings together and send then to one string argument in POST method.
So in example if I have Steven in first drop down and Peter chosen in second drop down I would like to send PeterSteven (or Peter,Steven or Peter Steven) in my POST method in controller.
I have tried using partial view for that part of the modal view but the problem is that all my drop down ID's are the same and that is not valid HTML.
I have used this approach for adding drop downs and it worked, just the ID's were the same and I could not get every selected value and put them together and send them to POST method in my controller.
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
I am open for new ideas, because I do not like the concept that I am using now.
I set up a web service using LAMP for personal use.
Basically, I have a scrollable list with some database information I pull once in the PHP script. I'd like to be able to click on one of the items, and have more information appear in a preview pane . (preview pane is set up)
I don't expect to ever have more than 100 entries in my database. Also, the data I'm pulling is very small...about 10 fields, all text data.
My question is as follows:
If I pull all the data I need in one shot, how can I store it so that each block of data I define (2-3 rows are what I need in the preview pane) is "cached" and I can access that given block at will so I can display it upon clicking its corresponding list entry?
Basically, this is about the same as clicking an email in a web-browser and having the rest of the message show up in a preview pane.
Thanks.
nb: the fact that I'm using a preview pane or a list is irrelevant. Just describing what I'm doing.
If I understand correctly, you would like to create a simple page, where several details are hidden until you click on different buttons. If you would like to do this in a "cached" way, you can try the following:
Fetch the complete data so that everything (with details) ends up in the result HTML. Everything: I mean, the parts which should be visible at all times and also the details which should be visible only after pressing a button.
Now, to the design. You will have to write CSS code, which will hide the details. (Of course, for that, you will have to create HTML in step 1 which will let you target the details via CSS classes, for example.) You will also have to figure out how to create buttons.
The most complicated part is to bind the buttons to Javascript actions, which will perform showing the hidden details. You can control all CSS properties from Javascript, so for example you can alter the position, the size, the text color etc. of a <div> dynamically.
Most people nowadays use jQuery for tasks like the one in step 3, or even software libraries built on the top of jQuery. That could help a lot if you're just starting out with tasks like this one. On the jQuery site, you will find a great place to start, called the jQuery Learning Center.
Edit: I've created a very basic fiddle to let you test the JS part of my concept, see it here: http://jsfiddle.net/eL9mj/22/