Deleting individual items in a multi-row agent

In this Lesson

You will

  • Learn how to delete individuals items displayed by a multi-row agent
  • Understand the delete operations impact on context
  • Modify the solution to allow parties to be deleted


Multi-row agents can declare their ability to remove individual items from their list by providing an event named delete. The event must be added to the Grid node that contains the list of items. This lets the designer know they have the option of removing individuals rows from the list/grid.

Declaring the event on the Grid node is only the first step. The agent must also provide an event handler capable of removing a single item from the list when the event is requested. [ ah … the old ‘say what you do’ and ‘do what you say’ game ]

There are two ways to create the event handler

  1. Have Soiree generate the event handler for you
  2. Write the event handler yourself

In this lesson you will be using option 1, however, let’s review how to use either option.

Generating the delete event handler

In order to have Soiree generate the delete event handler the following conditions must be met

  1. The agent must use a Soiree datasource to displays its information
  2. The agent must use a datasource method for the Delete data access option

The PartyList agent you created in a previous lesson provides a good example of generating a delete handler for a multi-row agent. Let’s review the way in which you created the PartyList agent.

The delete event was added to the Grid node named list when you selected the delete option in the Data Access section.

Because you built the PartyList agent with these settings it is already capable of deleting individual rows from the list. You do not need to make any changes to the agent in this lesson.

Writing the delete event handler

If you wanted to write the delete event handler yourself you would build an agent with the following definition

An event handler would not be generated because a datasource method is not specified. You would then have to create your own event handler by overriding the following method in your agent subclass

A word about context

In the Agent Introduction lesson you learned that agents operate inside a conversation. Their conversation is very much like conversations that people have: each conversation may have one or more topics that are being discussed and agents are free to add topics to the conversation, listen to the topics being discussed, and remove topics. These topics, in Soiree terms, are called the conversation’s context. Context is simply a collection of shared values which agents can publish and subscribe. The values are typically keys that represent some entity that exists in the conversation. For example, when a person selects a party the PartyList agent publishes the party id into context. Any agents that subscribe to party id will be asked to focus on the newly published party. This is what enables the single-row Party agent to display information about the party selected from the list.

When agents delete an entity they must remove that entity’s key from context. They do this by publishing null key values. When a null key is published it causes any subscribers to clear out the values in their scheme. For example, when the PartyList agent deletes a party we would expect the single-row Party agent to display no party at all after the delete occurs.

Modify the Party Pool solution to delete parties from the list

The PartyList agent you created in the previous lessons already provides a delete event. In this exercise you play the designer role and bind the delete event into the scene.

  1. Download these two images by right clicking on them and selecting Save Image As… from the pop-up menu.

    Small X

    Big X

  2. Open the PartyDefinition scene
  3. Drag the downloaded images into the scene’s Images library as shown here

  4. Drag the smaller / thinner icon into the row of the vertical styled as an Image Button. Resize the Party Name element to ensure it does not overlap the button as shown here

  5. Right click the image button, enable Confirm Click, and provide a confirmation message as shown here

  6. Scroll down in the image button’s property sheet and drag the larger / wider icon onto the Hover Image section

  7. Press OK to save the image button properties
  8. Switch to the Agent Binding perspective and drag the list grid node’s delete event to the image button. Right click on the image button to see its bindings.

  9. Save the scene
Test the solution
  1. Start the solution
  2. Advance to the party list
  3. Select a party from the list. This will cause the party information to be displayed from the Party agent.
  4. Move the mouse over the close button of a row in the party list. The icon should get larger when your mouse passes over it.
  5. Click the delete button for one of the parties in the list. The confirmation window should appear

  6. Confirming the action should cause the party to be deleted from the table and removed from the scene.
  7. The Party agent should no longer display any party information because a null party id was published by the PartyList agent.

That’s all for this lesson!