Cascading Dropdowns while in Sharepoint gridview RRS feed

  • Question

  • I've been assigned to create cascading dropdowns on a sharepoint list and I've gotten it to work on the default new form, but I can't seem to get it working with gridview. First, is this even possible, because I've been researching and couldn't find anything.

    Here is my code for the working cascade on a form:

    <script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
                parentFormField: "State", //Display name on form of field from parent list
                childList: "Cities", //List name of child list
                childLookupField: "Title", //Internal field name in Child List used in lookup
                childFormField: "City", //Display name on form of the child field
                parentFieldInChildList: "State" //Internal field name in Child List of the parent field
        function HillbillyCascade(params)
            var parent = $("select[Title='"+params.parentField+"'], select[Title='"+
                params.parentField+" Required Field']");
            var currentParent = $(parent).val();
            if (currentParent != 0)       
        function DoHillbillyCascade(parentID,params)
            var child = $("select[Title='"+params.childField+"'], select[Title='"+
                params.childField+" Required Field']," +
               "select[Title='"+params.childField+" possible values']");
            var options = "";
            var call = $.ajax({
                url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('"+params.childList+
                    "/Id eq "+ parentID,
                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 +"'>"+
            call.fail(function (jqXHR,textStatus,errorThrown){
                alert("Error retrieving information from list: " + params.childList + jqXHR.responseText);

    Tuesday, June 14, 2016 5:51 PM


All replies