4 tiered cascading drop-downs with 'none' option

Discussions about Cross-site Lookup
Locked
User avatar
Nigel Hertz
Posts: 9
Joined: Tue Nov 10, 2015
Contact:

10 Nov 2015

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

10 Nov 2015

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.

User avatar
Nigel Hertz
Posts: 9
Joined: Tue Nov 10, 2015
Contact:

10 Nov 2015

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 :)

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests