jbonfardeci / ShockoutForms

SharePoint + Knockout MVVM forms - an InfoPath killer
32 stars 8 forks source link

Cascading drop down #4

Closed leolorenzoluis closed 8 years ago

leolorenzoluis commented 8 years ago

Is cascading drop down supported?

bnsc commented 8 years ago

I would make this happen by writing some code in the prerender and postrender of the form code (let me know if you want me to put together an example). As of right now, cascading drop downs are not a template field, but it is possible to make this type of field configuration happen.

Thank you, Bill

leolorenzoluis commented 8 years ago

Yeah, that would be awesome. But then I have a requirement where some of the cascading drop down list should not be visible to certain people like only for supervisors. What does YourSupervisor() do?

jbonfardeci commented 8 years ago

YourSupervisor is a Person column in the example template list. You can restrict access to elements by adding a data-sp-groups attribute to the element with a delimited list of SP user group names such as: <div data-sp-groups="1;#Managers,2;#Admin"></div> The group IDs are optional but make sure your group names never change. So this: <div data-sp-groups="Managers,Admin"></div> will also work. It was my oversight for forgetting to update the example list templates when I added new columns. Apologies.

jbonfardeci commented 8 years ago

There are at least a couple of scenarios for feeding data to a custom cascading menu component: using options from 2 or more SP lists or options from 2 or more Choice fields within the parent list. Which is yours?

bnsc commented 8 years ago

How familiar are you with KnockoutJS?

The vm.YourSupervisor() function returns the value of YourSupervisor. This is a knockout variable (looks like a function because to obtain a value from a knockout bound object, you call the function with the name of the object).

Visibility of controls like you are suggesting can be accomplished by using the KnockoutJS visible: binding. The binding can be tied to the results of spForm.currentUserIsMemberOfGroups('SharePoint Group Name')

note: if you are not using any data-sp-groups attributes in the form, no groups will be pulled for the form's current user. In this situation, I suggest you add a hidden field with a data-sp-group attribute to kickstart the SharePoint groups array.

Thanks, Bill

leolorenzoluis commented 8 years ago

@jbonfardeci Current option I'm using is to use 2 or more lists with relationship, so based on the first selected list it propagates down to third list (if applicable)

List A : A, B, C List B : B, C ,D List C : D, E, F

@bnsc I haven't used KnockoutJS (only heard about it) but I am familiar with other javascript frameworks.