1

I have a Sharepoint-hosted app. When you click on "No Title" in a list you get a new window where the items is being showed. What I want is, when user click on "No Title" in the list it should pop up a dialog box that shows all items.

I'm using javascript!

enter image description here

Jordan:

I've tried now but didnt get it to work should the dialog come up when you press on the "No Title" or am i doing somthing wrong?

var clientContext, hostweburl, parentContext, parentWeb, list, listId, itemIds;

clientContext = new SP.ClientContext.get_current();
hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
listId = decodeURIComponent(getQueryStringParameter("SPListId"));
itemIds = decodeURIComponent(getQueryStringParameter("SPListItemId"))
parentContext = new SP.AppContextSite(clientContext, hostweburl);
parentWeb = parentContext.get_web();
list = parentWeb.get_lists().getByTitle("CoromaticIFU");


$(document).ready(function () {
$("#tabs").tabs();
$(document).tooltip();
$('#GEN_4').datepicker({ dateFormat: 'yy-mm-dd' }).val();
$('#save').click(setItems);


//Getting id and title variables to pass into the Edit form
var funString = "../Lists/CoromaticIFU/DispForm.aspx?ID=";
$("a[id*='item']").click(function(){ 
    var number = $(this).attr("name");
    var title = $(this).text();
    showDialogGetID(funString, number, title); return false;}); 
});


function showDialogGetID (url, id, title) {
url = url + id;

if (typeof url != "string")
    throw new Error.argument("url", "Expected a string.");

var options = {};
options.title = title;
options.url = url;

SP.UI.ModalDialog.showModalDialog(options);
}  




function setItems() {
var listCreationInformation = new SP.ListItemCreationInformation(), listItem = list.addItem(listCreationInformation);

listItem.set_item('GEN_1_Sum_Scope_Assigment', $('#GEN_1').val());
listItem.set_item('GEN_1_Sum_Scope_Assigment_D', $('#GEN_1_D').val());
listItem.set_item('GEN_2_CRMname', $('#GEN_2').val());
listItem.set_item('GEN_2_CRMname_D', $('#GEN_2_D').val());
listItem.update();

clientContext.load(listItem);
clientContext.executeQueryAsync(function (success) { alert("Din sparning lyckades!"); }, function (sender, args) { alert('Error:' + args.get_message()); });   
}
1

Go to List Settings -> Advanced Settings -> Launch forms in a dialog?. Check Yes here.

Update

The corresponding property which needs to be set in code is NavigateForFormsPages. Here is a sample schema.xaml file of a List Definition containing this attribute:

<List xmlns:ows="Microsoft SharePoint" Title="ClientAnnouncementsListDef" Url="Lists/ClientAnnouncementsListDef" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" NavigateForFormsPages="FALSE">
  <MetaData>
    ....
  </MetaData>
</List>
  • Ok thanks but how can i do it with code becuse when you get this dialog with all items i want my own survey form to come up and show all the items in textboxes you know how to do that? – linkan94 Oct 27 '14 at 13:05
  • Where in my app.js do i put this line of code to get to work? – linkan94 Oct 27 '14 at 13:12
  • Can you share how you are creating the list? – Nadeem Yousuf Oct 27 '14 at 13:17
  • Trough site content -> add an app -> custom list – linkan94 Oct 27 '14 at 13:21
  • I am not sure I understand your question properly. If you want to simply open the items in popup and you are creating a list manually through UI, then you can set the property as I described in the answer – Nadeem Yousuf Oct 27 '14 at 13:23
0

I use this launch a modal dialog. You can create any edit form or display form to point this to.

$(document).ready(function() { 
  //Getting id and title variables to pass into the Edit form
  var funString = "../Lists/ListName/EditForm.aspx?ID=";
  $("a[id*='item']").click(function(){ 
    var number = $(this).attr("name");
    var title = $(this).text();
    showDialogGetID(funString, number, title); return false;}); 
});

//function used for EditForm
function showDialogGetID (url, id, title) {
  url = url + id;

  if (typeof url != "string")
    throw new Error.argument("url", "Expected a string.");

  var options = {};
  options.title = title;
  options.url = url;

  SP.UI.ModalDialog.showModalDialog(options);
}   

I use data views to display the list which allows me to place my ID in the name property and pull it from here when I run my function.

Noticed you want to view all items instead of display for individual. I haven't tested it, but you could try putting the list URL in instead of the Edit/Display form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.