Load column on drop down change selection in mvc JavaScript - 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.

Related

How to do a person search and return back those lines in a select group of spreadsheets in a SharePoint document library

I have a need for a user to type in a name of a user on a SharePoint page and have it only look for all occurrences of this name in a series of spreadsheets stored in a single document library. This should return a series of lines where this person's name found.
A few things.
- The names used in the spreadsheets are not exact matches to those in
SharePoint and in fact will be first last instead of last, First as
in SharePoint. Maybe only accepting last names?
- These spreadsheets do have a property called Deliverable set to RACI.
- The spreadsheet lines look like this: Sponsor,DHS,Krista Willing,A,A,A,R,A,A,A
I have started the design and my first web part is a list filter allowing the user to pick a name. I then want to take the last name of what is selected and do a search in a document library for all the RACI (excel documents with RACI as a property) and display the results. This last part I'm still trying to figure out.
We can implement this using customizing the display template and content search webpart, please refer the below link how to customize the display template :
Content By Search Web Part
Content By Search Web Part(CSWP) was introduced in SharePoint 2013. CSWP has power to display dynamic content from SharePoint search index, based on dynamic search queries. It uses Display Templates for styling and formatting search results on the page. A big advantage of using CSWP over CQWP is, there are no scope boundaries for getting data across sites. However freshness of results depends on the latest crawl on content.
Display Templates 
Display Templates are used with CSWP to format/style search result generated by CSWP search query. Display Templates control which managed property is shown in the search results and how they appear in the Web Part. Each Display Template has two files: an HTML version of the Display Template that you can edit in your HTML editor, and a .js file that is for SharePoint use and should never be modified. CSWP uses combination of two Display Templates, Control Templates and Item Templates to render results.                         
Control Template provides HTML to structure the overall layout for how you want to present the search results.For example, the Control Template might provide the HTML for a heading, beginning and end of a list. The Control Template is rendered only once in the Web Part.
Item Template provides HTML that determines how each item in the result set is displayed. For example, the Item Display Template might provide the HTML for a list item that contains a picture, three lines of text that are mapped to different managed properties associated with the item. The Item Display Template is rendered one time for each item in the result set. So, if the result set contains ten items, the Item Display Template creates its section of HTML ten times. 
https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/92/84/8233.figure2.jpg
There will be two display templates
Header or control Display template
Item Display template
We need to customize the item display template. Process is - download the default item display template from display template gallery, rename the file name, do the customization, upload back the customized display template, publish it, go to content search web part, from web part setting select the newly updated item display template.
Sample item display template code :
<mso:ManagedPropertyMapping msdt:dt="string">'Picture URL'{Picture URL}:'PublishingImage;PictureURL;PictureThumbnailURL','Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'Description','Line 3'{Line 3}:'','SecondaryFileExtension','ContentTypeId', 'FileExtension'{FileExtension}:'FileExtension
https://blogs.technet.microsoft.com/sharepoint_quick_reads/2013/08/01/sharepoint-2013-customize-display-template-for-content-by-search-web-part-cswp-part-1/

Generic form with angular spring

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.

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.

How to access items of a .net collection using jquery in webforms

Within an asp webform project I am making a call to a web service that returns a result collection as follows.
Pseudo code return of collection
content (items are key value pair)
ID, 001
Title , My Book
DateCreated , 10/10/2011
Author, JSmith
What I would like to do is on the initial return only display the title of the book in a data repeater and then once the user clicks on a detail display the remaining fields in a separate pane div container of the form. I've done this in the past with generic lists in Silverlight and in MVC however in this project I cannot use either.
In conducting some research I have seen where people are using json to make similar calls. However I debugged with fiddler and I can see that entire collection is being returned to the UI so it seems I should be able to go directly at the collection vs making a new call back to the server? Within the UI I am not using asp:net controls but standard html to render the data in the data in the UI.
Example
<div class="resultcontainer">
<span class="labeltitle-small">Book Title</span><br />
<%= BookResults[0].Title %>
</div>
I'm able to query and return the results however where I am stuck is the best approach to display what I'll refer to as secondary data for the associated record.
I'd really appreciate any suggestions on how (from the client) to only show a view value of the collection and then once a record is selected have the other values displayed to the user.
Thank you
Well, perhaps a bit obvious, but have you considered a little bit of AJAX, using jQuery.ajax? You could attach an onclick even handler to the div and load the data in the appropriate part of the page when the user selects a particular book.
You can return a partial view from the controller. The resulting HTML can be displayed in a div using something along the lines of $("#detailDiv").html(partialView).

how to populate the state and city in my project without using AJAX and refresh page?

I am looking a sample for the functionality where there are 2 drop downs. One is 1 is State/Province and the 2rd is City. Based on the state drop down selection, city drop down values should be populated.
I need sample database design also....
Could anyone please help me out on getting a sample for this.
Regards
padman..
With neither Ajax nor refreshes? Bad idea, unless you have a very limited number of state/city combinations--otherwise the HTML/JavaScript you send will be huge.
Otherwise it's a simple dependent select, which is searchable on the web. The nutshell version is that when your state changes, you take the value of the selected state option, use it to look up cities in a map of state id => cities, and use the cities collection to populate the second select box.
The state/cities JavaScript structure is created on the server side using whatever template mechanism the rest of the app uses (I assume JSP or Velocity since you're using Struts 1).
DB DB design for what? States and cities? Have a table of states. Have a table of cities with a state id foreign key.

Categories

Resources