none
in SharePoint 2013 list EditForm.aspx - what JavaScript/JQuery/REST API codes can do this? RRS feed

  • Question

  • Hi all,

    This is exactly what I am trying to achieve. Workarounds will not work in my situation:

    Thanks so much!

    // On EditForm.aspx (in SharePoint 2013) // I need some JavaScript/JQuery/Rest api code (that could go in CEWP) to do: foreach (splistcolumns) { if (SPListColumnValue is not NULL) { //output column name
    //output column value

    } }




    • Edited by ran009 Monday, March 13, 2017 6:00 PM
    Sunday, March 12, 2017 4:54 PM

All replies

  • Hi,

    If you want to print form, you could build form by jQuery and then print by print function provided by jQuery library, here are some links for your reference.

    http://doersguild.github.io/jQuery.print/demo/

    http://stackoverflow.com/questions/17431760/create-a-form-dynamically-with-jquery-and-submit

    If this doesn’t help, could you provide more details for your requirement.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, March 13, 2017 2:06 AM
  • Hi Lee,

    Sorry, this is not what I need. My need is SharePoint specific.

    Any other thoughts are welcome!

    Thanks.

    Monday, March 13, 2017 6:01 PM
  • Hi,

    Seems you want to hide the field if it’s empty?

    If so, you could try to hide the field by jQuery, here is sample code for your reference(you may need more logic if you have fields not render as text box, like option).

    <script type="text/javascript">
            $(function () {
                $.each($('td.ms-formbody').find('input'), function () {
                    // Trim off all white spaces
                    // Check the string length – if it’s 0 hide the field
                    var val = $(this).val();
                    if (val.length > 0) {
                        if (val.replace(/\s|\xA0/g, '').length == 0)
                            $(this).parents('tr:first').hide();
                    } else {
                        $(this).parents('tr:first').hide();
                    }
    
                });
            });
        </script>

    Insert script editor web part for your list edit form, then add the code to script editor.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, March 14, 2017 10:31 AM