Page 1 of 1

4 tiered cascading drop-downs with 'none' option

Posted: 10 Nov 2015
by Nigel Hertz
Hi, we have a situation where we have a department, region, group and team that are configured via cascading dropdowns. Each level below department has an option of being "none" (i.e. departmental manager).

I've gone and added several "none" values (for each option really) which works fine when editing via the forms, however if you go in via dtasheet view, there's around 30 versions of "none" depending on the scenario. Is there any way around this?



E.G.

Dept-1 Region-1 Group-1 None

Dept-1 Region-1 None None

Dept-1 None None None

Dept-2 Region-4 Group-3 Team-6

Dept-2 Region-4 Group-3 None

Dept-3 None None None

Dept-4 Region-6 None None

Re: 4 tiered cascading drop-downs with 'none' option

Posted: 10 Nov 2015
by rostislav
Hello,

You can simply have one "none" entry per list instead of the 30 and include that entry in your filtering using the or operator, like this (using the example from the how-to):

Code: Select all

function (term, page) {
  // Getting the selected country
  var countryId = fd.field('Country').value();
  if (!countryId) {
    countryId = 0;
  }

  //the id of the "none" entry
  var noneId = 2;

  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Country/Id&$orderby=Created desc&$expand=Country/Id&$filter=Country/Id eq " + countryId + " or Id eq " + noneId + "&$top=10";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Country/Id&$orderby={LookupField}&$expand=Country/Id&$filter=startswith({LookupField}, '" + term + "') and (Country/Id eq " + countryId  + "or Id eq " + noneId + ")&$top=10";
}
This will solve the multiplication of none records, however do note that you cannot have cascading dropdowns in the data sheet view, in case you were trying the implement that. If needed, you can disable the quick edit mode of the data sheet view so as to prohibit wrong data entry, see this link on how to achieve this.

Re: 4 tiered cascading drop-downs with 'none' option

Posted: 10 Nov 2015
by Nigel Hertz
Brilliant, thank you very much for that. That's exactly what I was looking for.


I had a feeling it might not work in datasheet view; that's not a problem - just education for the users :)