Modify or add jQuery to show unlimited entries from another lookup list from SharePoint Online

Discussion in 'jQuery' started by kouliscon, Jan 15, 2019.

  1. #1
    [​IMG]
    0
    Hello all,

    I am using from a online post which you have cascading parent/ child/ grandchild list with the help of two jQuery's.

    Main js.file

    --------------------------------------------------------------------

    $.fn.HillbillyCascade= function (optionsArray)
    {
    var Cascades = new Array();

    var NewForm = getParameterByName("ID") == null;

    $.fn.HillbillyCascade.Cascade = function(parent,cascadeIndex)
    {
    if (cascadeIndex!= null && cascadeIndex+1 > Cascades.length)
    {
    return;
    } else if(cascadeIndex== null) {
    cascadeIndex= $(parent).attr("HillbillyCascadeIndex");
    }

    var params = Cascades[cascadeIndex];
    var parentID = $(parent).val();
    if (parent == null)
    {
    parentID = $("select[Title='"+params.parentFormField+"'], select[Title='"+
    params.parentFormField+" Required Field']").val();
    }
    if (parentID == undefined)
    {
    parentID = 0;
    }

    var child = $("select[Title='"+params.childFormField+"'], select[Title='"+
    params.childFormField+" Required Field']," +
    "select[Title='"+params.childFormField+" possible values']");

    var currentVal = params.currentValue;
    Cascades[cascadeIndex].currentValue = 0;

    $(child).empty();

    var options = "<option value='0'>"+params.firstOptionText+"</option>";

    var call = $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('"+params.childList+
    "')/items?$select=Id,"+params.childLookupField+","+params.parentFieldInChildList+
    "/Id&$expand="+params.parentFieldInChildList+"/Id&$filter="+params.parentFieldInChildList+
    "/Id eq "+ parentID+"&$orderby=" + params.childLookupField,
    type: "GET",
    dataType: "json",
    headers: {
    Accept: "application/json;odata=verbose"
    }

    });
    call.done(function (data,textStatus, jqXHR){
    for (index in data.d.results)
    {
    options += "<option value='"+ data.d.results[index].Id +"'>"+
    data.d.results[index][params.childLookupField]+"</option>";
    }
    $(child).append(options);
    if(!NewForm)$(child).val(currentVal);
    $().HillbillyCascade.Cascade(null,Number(cascadeIndex)+1);
    });
    call.fail(function (jqXHR,textStatus,errorThrown){
    alert("Error retrieving information from list: " + params.childList + jqXHR.responseText);
    $(child).append(options);
    });
    }

    for (index in optionsArray)
    {
    var thisCascade = optionsArray[index];

    if(thisCascade.parentFormField != null)
    {
    var parent = $("select[Title='"+thisCascade.parentFormField+"'], select[Title='"+
    thisCascade.parentFormField+" Required Field']");

    $(parent).attr("HillbillyCascadeIndex",index);

    $(parent).change(function(){
    $().HillbillyCascade.Cascade(this,null);
    });
    }
    thisCascade.currentValue = $("select[Title='"+thisCascade.childFormField+"'], select[Title='"+
    thisCascade.childFormField+" Required Field']," +
    "select[Title='"+thisCascade.childFormField+" possible values']").val();

    Cascades.push(thisCascade);
    }

    $().HillbillyCascade.Cascade(null,0);


    function getParameterByName(key) {
    key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
    var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
    return match && decodeURIComponent(match[1].replace(/\+/g, " "));
    }
    }
    --------------------------------------------------------------------------------------



    and secondary jQuery file



    ---------------------------------------------------------------------------------------

    <script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
    < script src="../../SiteAssets/HillbillyCascade.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {

    var cascadeArray = new Array();

    cascadeArray.push({
    parentFormField: "Event_Indoor_Outdoor", //Display name on form of field from parent list
    childList: "Event_Location", //List name of child list
    childLookupField: "Title", //Internal field name in Child List used in lookup
    childFormField: "Event_Location", //Display name on form of the child field
    parentFieldInChildList: "Event_Indoor_Outdoor", //Internal field name in Child List of the parent field
    firstOptionText: "< Select if is Indoor or Outdoor >"
    });

    cascadeArray.push({
    parentFormField: "Event_Location", //Display name on form of field from parent list
    childList: "Event_Location_Room_or_Type", //List name of child list
    childLookupField: "Title", //Internal field name in Child List used in lookup
    childFormField: "Event_Location_Room_or_Type", //Display name on form of the child field
    parentFieldInChildList: "Event_Location", //Internal field name in Child List of the parent field
    firstOptionText: "< Select a Location >"
    });

    cascadeArray.push({
    parentFormField: "Event_Location_Room_or_Type", //Display name on form of field from parent list
    childList: "Event_Grove_or_Field", //List name of child list
    childLookupField: "Title", //Internal field name in Child List used in lookup
    childFormField: "Event_Grove_or_Field", //Display name on form of the child field
    parentFieldInChildList: "Event_Location_Room_or_Type", //Internal field name in Child List of the parent field
    firstOptionText: "< Select a Grove or Field >"
    });

    $().HillbillyCascade(cascadeArray);

    });


    < /script>

    -----------------------------------------------------------------------------------



    now at the first jQuery file the dropdown list are limited to 100 items, how can I make this unlimited?



    thank you in advance.
     
    kouliscon, Jan 15, 2019 IP