Count and sum fields from related items table

rss

Posted by Jaydius - Nov 16 ’16 at 04:43

Is it possible to count the number of records in a related items table, and then use the total value to populate a form field e.g. 'Total Related Items'?

Also, is it possible to sum a number field from all related items and also use that totalised value to populate a form field, such as 'Total Hours'?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 9 months 13 days
    #1 by Dmitry Kozlov Nov 17 ’16 at 04:48

    Here is how you can get data from the related items control:

    fd.relatedItems(0).data('ctx').ListData.Row[0].Title
    

    where the first index is 0-based index of the Related Items control in a page, the second – index of the row in the Related Items control, and Title is the internal name of a field.

    Just sum values from the required column and put it into a field.

  • joetel8
    Member
    Member for: 3 years 5 months 8 days
    #2 by joetel8 Mar 19 ’17 at 07:32

    Hello,

    I noticed the person who posted this question did not respond to your solution.  I am needing more information on this solution.  When you say.. that the "Title" is the internal name, are you refering to the internal name of the field in the related item table?

     

    Joe

  • joetel8
    Member
    Member for: 3 years 5 months 8 days
    #3 by joetel8 Mar 19 ’17 at 07:42

    [#2]:  Follow up question.  I wanted to place a border around the column header of related item list.

    I was able to use css to place a border around the body of the table by applying this:

    .ms-listviewtable > tbody > tr > td { border: 1px black solid;}

    but I am not able to do the same to the column header.

    Thank you in advance.

    Joe

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 9 months 13 days
    #4 by Dmitry Kozlov Mar 20 ’17 at 06:42

    [#2]: Yes, the internal name of a field in the related list.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 9 months 13 days
    #5 by Dmitry Kozlov Mar 20 ’17 at 06:46

    [#3]: Please, use the CSS:

    .ms-listviewtable > thead > tr > th { border: 1px black solid;}

    Please, ask future questions in our new forum:

    http://spform.com/forum

  • kimann
    Member
    Member for: 2 months 20 days
    #6 by kimann Apr 15 ’20 at 06:36

    Well considering this suggestion, it makes me remind of something I studied few months back and which said that using execcive HTML table tags may heart your crawling budget google normally assigns every website like www.CheapEssayWriter.com since gogle search bots do not appreciate when they see more tags while crawling your website

  • danikhan
    Member
    Member for: 2 days
    #7 by danikhan Jul 1 ’20 at 02:03

    Thank you for posting very useful tips! I found your website perfect for my needs.I always like your article because you have provide every time informative post..Thanks!  Genuine Leather Jacket Womens | Pay Someone To Do My Essay Uk

  • danikhan
    Member
    Member for: 2 days
    #8 by danikhan Jul 1 ’20 at 02:05

    Thank you for posting very useful tips! I found your website perfect for my needs.I always like your article because you have provide every time informative post..Thanks! https://www.essaymania.co.uk/write-my-essay

Displaying 1 to 8 of 8 messages