Page 1 of 1

Links from related Items

Posted: 14 Feb 2018
by TonyDuke
Good Afternoon,

I have a display form with a number of related items views and for 2 of the views when a user clicks on any item in the view we need to open the item full screen either in the same window/tab or in a new window/tab rather than modal.
Is this possible?

Thanks

Re: Links from related Items

Posted: 14 Feb 2018
by Nikita Kurguzov
Dear Tony,
In general, I recommend the following code:

Code: Select all

$('.ms-listlink').click(function(){
  window.location.href = $(this).attr('href');
});
But since you need it only for 2 of Related Items and not all, you can probably give a class (no-dialog, for example) to these Related Items and use it to be more specific:

Code: Select all

$('.no-dialog .ms-listlink').click(function(){
  window.location.href = $(this).attr('href');
});

Re: Links from related Items

Posted: 16 Feb 2018
by TonyDuke
Hi Nikita,

I have tried both of those and nothing seems to have changed all items still open in Dialog.

As I said previously the form with the related items views on is a display form, unsure if that makes a difference?
I have also attached a couple of images showing how the related items are setup again unsure if that matters.
Capture1.PNG
Capture1.PNG (23.4 KiB) Viewed 6621 times
Capture2.PNG
Capture2.PNG (25.53 KiB) Viewed 6621 times
I am assuming I should simply paste the code within the JavaScript editor?
Also to give the related item a class again I am assuming I can do this by putting the no-dialog into the Css Class under Layout on the right hand toolbar within forms designer?

If the above is correct I can't see what else could be wrong?

Thanks

Re: Links from related Items

Posted: 16 Feb 2018
by Nikita Kurguzov
Dear Tony,
The reason the code didn't work is most likely that you are using Server render and the code is for Client render.
But since you use Server render, this should work, try it out:

Code: Select all

$('.ms-vb a').click(function(){
  window.location.href = $(this).attr('href');
});

Re: Links from related Items

Posted: 16 Feb 2018
by TonyDuke
Hi Nikita,

Ok if I change my related items views to client render the original code you supplied works well, however the new code for server render does not appear to do anything.

The reason I have to use server render is that one of the related items views I have uses a view that is grouped and if I use client render all items are shown under each group i.e. 10 items in list, grouped by status 5 completed and 5 uncompleted, in server render 5 items are shown in each group. In client render all 10 items are shown under each group.

Any ideas on either how I can resolve the issue so I can change the related items to client render or why the code for server render doesn't work??

Thanks

Re: Links from related Items

Posted: 19 Feb 2018
by Nikita Kurguzov
Dear Tony,
That the code doesn't work with server render is strange as I've personally tested the code myself prior to posting it. Can you tell me which version of SharePoint you are using, so I can test it with it? I did my tests in SharePoint Online, it can be different for your version of SP.

Alternatively, it would be the best if you could save the page HTML where the form is. Open the form with Related items in server render mode, right click somewhere on the page, click Save as... And send me the file. That would ensure that I can check your own form and write the code that will work for you.

Re: Links from related Items

Posted: 28 May 2021
by cboehme
Nikita Kurguzov wrote:
14 Feb 2018
Dear Tony,
In general, I recommend the following code:

Code: Select all

$('.ms-listlink').click(function(){
  window.location.href = $(this).attr('href');
});
But since you need it only for 2 of Related Items and not all, you can probably give a class (no-dialog, for example) to these Related Items and use it to be more specific:

Code: Select all

$('.no-dialog .ms-listlink').click(function(){
  window.location.href = $(this).attr('href');
});
Hello Nikita, thanks for this solution.
That really meets my needs. ;)

But, is there a chance to pass the source url (parent in display or edit form) on close/cancel of the child (in display form) to redirect to that previous source (parent) :?:
Yet, on close user will be redirected to the child item list in standard view.

Thanks for your reply in advance!

Sincerely,
Christian

Re: Links from related Items

Posted: 07 Jun 2021
by Nikita Kurguzov
Dear Christian,
Please, try the following:

Code: Select all

$('.ms-listlink').click(function(){
  window.location.href = $(this).attr('href') + "&source=" + window.location.href.split("?")[0];
})