Muthuselvakumar
Muthuselvakumar

Reputation: 1

how to use cascade dropdown in serenity?

[DisplayName("Team"), LookupEditor(typeof(TeamRow))]
public int? TeamId
{
    get => fields.TeamId[this];
    set => fields.TeamId[this] = value;
}

[DisplayName("Assigned To"), LookupEditor(typeof(UserRow), cascadfrom = "TeamId"),         TextualField("Username")]
public int? AssignedTo
{
   get => fields.AssignedTo[this];
   set => fields.AssignedTo[this] = value;
}

I create a Serenity form with team and user columns. now i have to select the dropdown users based on the team. the team have multi select in user table. can anyone help me with this

Upvotes: 0

Views: 73

Answers (2)

Muhammed Yaman
Muhammed Yaman

Reputation: 11

You need to add CascadeField to match the TeamId with the field on your UsersRow. Like below:

 [DisplayName("Assigned To"), LookupEditor(typeof(UserRow), CascadeField = "TeamId", CascadeFrom = "TeamId"), TextualField("Username")]
    public int? AssignedTo
    {
       get => fields.AssignedTo[this];
       set => fields.AssignedTo[this] = value;
    }

Upvotes: 0

David Lawrence
David Lawrence

Reputation: 1

 public inputID: number;
 protected afterLoadEntity() {
     super.afterLoadEntity();
     this.inputID = this.entity.TeamId;
     this.form.AssignedTo.cascadeValue = 6;
 }

Try using this code in dialog.ts file.

Upvotes: 0

Related Questions