2

I have multi select cascading in list newform.aspx, like in the picture below. I have values in my column, it is not shown in the picture below.

enter image description here

Duplicate values also come in my second column. I have code to remove duplicates from this column.

var usedNames = {};
$("select[title='TitleColumn'] > option").each(function () {
    if(usedNames[this.text]) {
        $(this).remove();
    } else {
        usedNames[this.text] = this.value;
    }
});

I wanted to know what event should I execute this code so that when items are selected in the first column and when the second column gets populated, it should only show unique values.

1 Answer 1

3

Duplicates can also be removed when cascading is done like in below cascading code we can call a function to remove duplicate.

$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: "",
  relationshipList: "",
  relationshipListParentColumn: "",
  relationshipListChildColumn: "",
  relationshipListSortColumn: "",
  parentColumn: "",
  childColumn: "",
  CAMLQuery: "",
  CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", // Added in 2013.01
  listName: $().SPServices.SPListNameFromUrl(),
  promptText: "",
  simpleChild: false,           
  selectSingleOption: false,    
  matchOnId: false,             
  completefunc: RemoveDuplicate,
  debug: false
});


function RemoveDuplicate()
{
var usedNames = {};
$("select[title='Title possible values'] > option").each(function () {
        if(usedNames[this.text]) {
            $(this).remove();
        } else {
        usedNames[this.text] = this.value;
        }
    });
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.