Page 1 of 1

Dynamically Hide Column in Related-Item

Posted: 17 Jan 2020
by ksertkaya
Hello,

Is there any way dynamically hide column in related-item?
Screenshot_38.png
Screenshot_38.png (15.75 KiB) Viewed 3574 times

Re: Dynamically Hide Column in Related-Item

Posted: 20 Jan 2020
by mnikitina
Hello ksertkaya,

Please find the code example in this post:
viewtopic.php?p=7611#p7611

Re: Dynamically Hide Column in Related-Item

Posted: 21 Jan 2020
by ksertkaya
Thank you :)

Another question : How can I set max column width this column? I changed column's value but it seems like they have been overlaped. How can I set auto-fix?

Code: Select all

$('.RelatedItem a.ms-headerSortTitleLink')[index].text  =  item[0].Column1;
Screenshot_41.png
Screenshot_41.png (17.08 KiB) Viewed 3548 times

Re: Dynamically Hide Column in Related-Item

Posted: 22 Jan 2020
by mnikitina
ksertkaya,

You can set the width of the columns with the CSS.

For all columns please use this CSS:

Code: Select all

.ms-viewheadertr th {
   width: 350px;
}
And if you want to change the width of a specific column only, use this CSS:

Code: Select all

.ms-viewheadertr th:nth-child(5) {
   width: 350px;
}
Note that you should replace '5' with an index of the column that you want to format.

Re: Dynamically Hide Column in Related-Item

Posted: 27 Jan 2020
by ksertkaya
Hi,

This code works! Thank you :)

Another question : When I clicked edit button, All columns' name returned internal name. How can I fix this issue?
Screenshot_45.png
Screenshot_45.png (24.3 KiB) Viewed 3498 times
Screenshot_46.png
Screenshot_46.png (21.72 KiB) Viewed 3498 times
Regards.

Re: Dynamically Hide Column in Related-Item

Posted: 27 Jan 2020
by mnikitina
Hello ksertkaya,

The CSS classes of the column headers are different for a standard and quick edit views.

To change the column header in a quick edit view, please use the following code.

Code: Select all

$('.ms-spGrid-HeaderContentStyle')[0].innerText = 'New Title';

Re: Dynamically Hide Column in Related-Item

Posted: 28 Jan 2020
by ksertkaya
It works! Thanks a lot :)

Re: Dynamically Hide Column in Related-Item

Posted: 30 Jan 2020
by ksertkaya
Hello,

Another question :) : We would like to make an addition operation on quick edit mode in related item. When the values of the columns (please see screenshot) are entered, the sum of them will be calculated and entered in another column.
Screenshot_47.png
Screenshot_47.png (125.98 KiB) Viewed 3478 times

Re: Dynamically Hide Column in Related-Item

Posted: 30 Jan 2020
by Nikita Kurguzov
Dear Sertkaya,
Unfortunately, that's not possible, at least as far as I am aware. Maybe if you use Calculated column, then it could work.

The issue is that Related Items is just a regular SharePoint List view, there are no extra tools in our JS API for it. If there are solutions which work in Quick Edit mode in regular SharePoint lists, then they might work here as well.

P.S. Workflow might work, but you'll need to refresh Related Items manually, and it''s impossible to say when Workflow is ready.

You can use the following JS to refresh Related Items:

Code: Select all

fd.relatedItems(0).data('ctx').clvp.RefreshPagingEx('');