Page 1 of 2

Related-items Get Column Id

Posted: 19 Apr 2018
by ksertkaya
Hi,

1.How do I clear all textbox in table with code?
Screenshot_5.png
Screenshot_5.png (67.39 KiB) Viewed 1757 times
2. How do I get column id of first column in related-item?
Screenshot_4.png
Screenshot_4.png (24.08 KiB) Viewed 1757 times
Thanks in advance.

Re: Related-items Get Column Id

Posted: 19 Apr 2018
by Nikita Kurguzov
Dear Sertkaya,
1) To empty value of several text fields inside one table, first give this Table a CSS class like my-table, then use the following code:

Code: Select all

$('.my-table').find('.fd_field input').each(function(){
    this.value = '';
});
2) If you try to get the ID, try the following code:

Code: Select all

fd.relatedItems(0).data('ctx').ListData.Row[0].ID;
If not ID, but another field, just replace ID with the Internal name of the field. If you have more than one Related Items control, replace 0 in relatedItems() with the number of the correct Related Items control.

Re: Related-items Get Column Id

Posted: 19 Apr 2018
by ksertkaya
Thanks Nikita.

Another question :

How do I set required(Not just asteriks) one field with code? Is it possible?

Re: Related-items Get Column Id

Posted: 19 Apr 2018
by Nikita Kurguzov
Dear Sertkaya,
No, unfortunately it's not possible to make field mandatory with JavaScript. What you can do is use JavaScript validation instead of default SharePoint validation. Read more about it here - https://spform.com/javascript-framework ... ynamically

Re: Related-items Get Column Id

Posted: 20 Apr 2018
by ksertkaya
Hi again,

I try to get id/value from lookup but I can't.

alert(fd.relatedItems(0).data('ctx').ListData.Row[0].Okul);
Screenshot_8.png
Screenshot_8.png (28.69 KiB) Viewed 1740 times
Screenshot_7.png
Screenshot_7.png (6.76 KiB) Viewed 1740 times

Re: Related-items Get Column Id

Posted: 20 Apr 2018
by Nikita Kurguzov
Dear Sertkaya,
What type of field are you trying to get?

Re: Related-items Get Column Id

Posted: 20 Apr 2018
by ksertkaya
Lookup.

Re: Related-items Get Column Id

Posted: 20 Apr 2018
by Nikita Kurguzov
Dear Sertkaya,
Try the following code for Lookup instead:

Code: Select all

fd.relatedItems(0).data('ctx').ListData.Row[0].FIELD_NAME[0].lookupValue;

Re: Related-items Get Column Id

Posted: 20 Apr 2018
by ksertkaya
Thanks a lot!

Re: Related-items Get Column Id

Posted: 27 Apr 2018
by ksertkaya
Hi again,

My code is not working. CSS name of my table is 'Kaza'

Code: Select all

$('.Kaza').find('.fd_field input').each(function(){
    this.value = '';
});