Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample request: Contextual Ribbon UI #69

Closed
davidchesnut opened this issue Mar 20, 2020 · 0 comments
Closed

Sample request: Contextual Ribbon UI #69

davidchesnut opened this issue Mar 20, 2020 · 0 comments

Comments

@davidchesnut
Copy link
Member

We're breaking the large scenario Manage ribbon and task pane UI, and run code on doc open into smaller bite-size samples.

This request is to break out the part of the sample that shows how to manage Ribbon buttons being enabled or disabled based on context of the UI and user actions. The goal is to show how to use the Ribbon management APIs documented at Enable and Disable Add-in Commands

The sample should have the following Ribbon buttons.

  • Connect. This pretends to connect to some backend service. The only actual action is that it enables the other buttons (Disconnect, Insert data). Connect is disabled when Disconnect is enabled (these two toggle).
  • Disconnect. This pretends to disconnect from a backend service. It disables itself, and the Insert data button. It enables the Connect button.
  • Insert data. Inserts a mock table of data into the spreadsheet (this can be the same data from the original sample). The table is named so that you can hook up events to it.
  • Sum. This button is connect to a table selection changed even (which the original sample has code for). When in the table, the button is enabled. When outside of the table, it is disabled. if the table does not exist, it is disabled.

Additional notes:

  • The Sum button should be connected to the table selection changed event from Office.Initialize (if the table exists such as from a saved document)
  • There is no task pane. So this is a cool way to show that you can run code without a task pane.
  • You'll still need a global state object of some sort to track button state, and update it as the buttons are used and toggled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant