vLookup Hide viewField if no Data

Forums vLooup for SharePoint vLookup Hide viewField if no Data

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Ray Stopa 2 months ago.

  • Author
    Posts
  • #25602

    Ray Stopa
    Participant

    In vLookup, is there a way to hide a viewField column completely if no data is returned in any rows, while displaying other viewFields that do have data.

  • #25617

    Alexander Bautz
    Keymaster

    Hi,
    To to this you would have to run some custom js to look at every cell and hide it if it is empty in all rows.

    This should do the trick, but change vLookupTasks with the name of your vLookup field:

    function vLookupIsLoadedCallback(fin) {
        if (fin === "vLookupTasks") {
            setTimeout(function () {
                var tdTracker = {};
                jQuery(".vLookupTableRow").each(function (i, row) {
                    jQuery(row).find(".childTableCell").each(function (j, cell) {
                        if (tdTracker[j] === undefined) {
                            tdTracker[j] = false;
                        }
                        if (jQuery(cell).html() !== "") {
                            tdTracker[j] = true;
                        }
                    });
                });
                jQuery.each(tdTracker, function (i, v) {
                    if (!v) {
                        jQuery(".childTableHeaderRow td.childTableHeader:eq(" + i + ")").hide();
                        jQuery(".vLookupTableRow").each(function (j, row) {
                            jQuery(row).find("td.childTableCell:eq(" + i + ")").hide();
                        });
                        jQuery(".vLookupTotalsTR td.vLookupTotals:eq(" + i + ")").hide();
                    }
                });
            }, 10);
        }
    }

    Alexander

  • #25781

    Ray Stopa
    Participant

    Thank you Alex

You must be logged in to reply to this topic.