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

[PropertyGrid] Provide the ability to add custom header controls. #1107

Open
mdastous-bentley opened this issue Dec 5, 2024 · 6 comments
Open
Labels
enhancement New feature or request property widget Property grid widget and its components related issues

Comments

@mdastous-bentley
Copy link
Contributor

We want to add a custom 'Delete' button inside the property grid, that would allow the currently selected item(s):
Image

Somehow, it should also be possible to create access to the selection keys. Right now we have to rely on the the iModel connection's selection set.

@aruniverse aruniverse added the property widget Property grid widget and its components related issues label Dec 5, 2024
@aruniverse
Copy link
Member

Are you using a component from itwin/property-grid-react for that Properties tab, or a custom one wrapping a component from AppUI?

@grigasp
Copy link
Member

grigasp commented Dec 6, 2024

Are you using a component from itwin/property-grid-react for that Properties tab, or a custom one wrapping a component from AppUI?

I assume it's a component from @itwin/property-grid-react. However, @mdastous-bentley, can you specify which top-level component you're rendering? E.g. where do you expect the prop for header buttons to be exposed?

Right now we have to rely on the the iModel connection's selection set.

Ugh, that's definitely not the right thing to use. Instead, you should use Presentation.selection.getSelection(imodel).

@mdastous-bentley
Copy link
Contributor Author

We consume createPropertyGrid, code snippet:

export const createFeaturePropertyGrid = (opts: CreateFeaturePropertyGridOptions) => {
  const createDataProvider = (imodel: IModelConnection) => new FeaturePropertyDataProvider({ imodel, localization: opts.getLocalization() });
  const propertyGridProps = {
    autoExpandChildCategories: true,
    isPropertyEditingEnabled: true,
    onPropertyUpdated,
    createDataProvider,
    shouldShow: (selection: Readonly<KeySet>) => !selection.isEmpty,
  };

  const propertyGridWidget = createPropertyGrid(propertyGridProps);
  const featurePropertyGrid: Widget = {
    ...propertyGridWidget,
    content: 
    <GeospatialProvider contextProps={{localization: opts.getLocalization()}}>
      <div style={{width: "100%", height: "100%"}} >
        <FeaturePropertyDeleteButton />
        {propertyGridWidget.content}
      </div>
    </GeospatialProvider>
  };
  return featurePropertyGrid;
}

@grigasp grigasp added the enhancement New feature or request label Dec 9, 2024
@saskliutas
Copy link
Member

We have what we call Settings menu that renders a dropdown button in the property grid header: https://github.com/iTwin/viewer-components-react/blob/master/packages/itwin/property-grid/README.md#settings-menu

You can pass your custom items to it. https://github.com/iTwin/viewer-components-react/blob/master/packages/itwin/property-grid/README.md#custom-setting-menu-items

Would it be a viable place to render your Delete button? It does not support icons at the moment but it should be fairly easy change to add it.

@grigasp
Copy link
Member

grigasp commented Jan 6, 2025

@mdastous-bentley, did you get a chance to look at @saskliutas suggestion?

@mdastous-bentley
Copy link
Contributor Author

Not yet, but it sounds promising...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request property widget Property grid widget and its components related issues
Projects
None yet
Development

No branches or pull requests

4 participants