Generic form with angular spring - javascript

I'm planing to create generic form created dynamically with JSON data from server.
Assume a ng form, using ng repeat we populating dynamic form, based on the first set of JSON.
If the form has drop-down or radio elements there should be another call to get subset elements (textbox, radio) to populate under the parent drop down or radio.
If drop-down changes, sub form should be added under the parent drop down.
There is no workflow using those data. Only CRUD Operations are performed.
I'm planing this to do generically from angular controller till db design level.
How the db/service design should be for making Json for parent set?
How to link the parent and sub set even sub's subset?
How to save the data and do edit operation?
Also is it better idea to save data as Json in db column?

I am not sure if I understood your question but if you have an option to display a form from a set of forms, you can just create templates of those forms and display them on the dropdown select.
If it is a generic form template then I guess you only have to change the labels and the form names in those html templates. You can bind the values to the same model names to ng-model in the controller.
DB design depends on the nature of data you have, which you have not mentioned, so its tough to answer.
'JSON data' is the payload passed through your REST services. That has to do with how you design your response data. If its just form-templates details for the form suggested you've selected in the dropdown, then you can just pass the label names and data types for those fields.
So there will be 2 services.
1. A GET to get the Form template labels and field definitions.
2. A POST to submit the form.
Keep in mind that all these forms are defined at the beginning and not created on the fly. i.e you cannot create a new form-template on the fly.

Related

Load column on drop down change selection in mvc JavaScript

How to bring the employee name list in one column on selection of project name drop-down list? At the same time while besides employee name 1 textbox and one date filterbox also should generate dynamically. I'm am not good in scripting technologies need some guidance.
Here's how I would do it, if anyone has any criticisms please let me know!
In your controller action for the page return a list of Project objects in a View Model. Each Project object should have at least two properties; one for the name and one for a unique ID. In the Razor view for the page, render the Project objects via a the DropDownList HTML Helper.
Next, set up a Web API endpoint for retrieving a list of Employee's based on the Project they are assigned to.
In your Razor page which displays the lists, write some JavaScript which executes on change of the value of the Project DropDownList. The JavaScript should take the updated value of the Project dropdown, use this value to call the Web API endpoint for retrieving Employee's (based on Project ID), and render the resulting data in a HTML select element.

Ng-admin custom reference list - with ability to create new entry

I'm trying to figure out how I can make a custom directive which will combine:
reference list select field
create button which will show a reference entity creation view
and on creation save. reload reference list entities, so i can choose a newly created entity.
It can be easily done using completely custom code, but i want to make it using ng-admin templates and directives.
It's also quite common functionality, but i'm having a hard time integrating it into ng-admin.
So in case there is no required field in list, i will not loose data i already entered by navigating to create new entity on another page.
Add two fields:
one of type referenced_list to display related entries
one virtual field with an empty label and a custom template, using a create button with prefilled default values for the related entry (e.g. <ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>)
Check https://github.com/marmelab/ng-admin-demo/blob/3a0944acbcb12dc20dc8a4a860c6c9f8da9c1645/js/customers/config.js#L81-L101 for an example.

Dynamic Gravity list in jsp

I need to populate a drop down list in a jsp page form using the values fetched from the database. The condition is only few rows are fetched from the database based on the other fields of the form. How do i do this without using jQuery or other stuff? I'm quite new to coding, so i require help.
The scenario is, based on employee id entered, the state of the employee has to fetched from the database. And then based on the state fetched from database i need to create a drop down list containing the different office branches present in that state from the database. I dont want multiple pages for taking these details, just one form in a page. How to i populate such a dropdown box in a jsp page?
Either you have to go for jquery or AJAX which will populate your
data without an actual servlet request, or you have to do this
in two different forms.

Keeping a partial view model self contained but still able to get data based on an outside selector

This question leads to more of a discussion of methods instead of specific code/debugging.
I am working on an MVC project using knockout for dynamic data binding with c# on the front end. I have a partial view model, I want to populate with a list of data objects. I want to be able to do this without a postback using ajax calls using knockout for the data binding. The data call will depend on an outside selection such as a dropdown select box. What method/tool do I have available to me to keep this view model self contained without a dependency to a specific select box, but still be able to have the functionality I just explained?

Get data from unordered lists that are dynamically added to the page

I'm having a page where I can create some configuration sections and the page is structured as follows:
It has a button that adds a partial view to the page (using an AJAX call) and on this partial view I have:
Dropdown to select the section
List of available items
List of selected items
The list of selected items is populated using jQuery UI (sortable) via drag&drop. The items above can be repeated as much as the user wants. And I want to pass to the controller the data selected from all the dropdowns and from all the lists of selected items.
I have no idea how I can use a #model or even the ViewBag because the selected items list is initially empty and gets populated on the client side. As a side note, I don't need the list of available stuff.
UPDATE:
I've changed the question because I'm willing to put all the data in a form and I gave up the idea to use javascript to collect the data and make a request to my controller. So now I'm trying to use the FormCollection to get the data. The only problem is that when I submit the form FormCollection has no data in it.
UPDATE 2:
After looking into the FormCollection and ModelBinding I've came upon an impediment. I can't get the items on the form that don't have the name property. The problem is that the <ul> or <li> elements don't have the name attribute. So the question would be, how can I get the data from those elements using the above mentioned methods if they don't have name ?
I have found the solution: I gave up on using lists and moved to using the select multiple with the ui.multiselect plugin. This solved the problem as the select has the name attribute and I can get the data using FormCollection.

Categories

Resources