# TreeDataGridElementFactory

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls-treedatagrid/primitives/struct-treedatagridelementfactory/

**struct** · [`ferroui-controls-treedatagrid`](/docs/0.5.0/api/ferroui-controls-treedatagrid/) · v0.5.0

```rust
struct TreeDataGridElementFactory
```

Creates the elements of the presenters and keeps the recycled ones, by recycle key and by the
parent they were recycled from.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L91)

## Members

- [`new`](#function-new)
- [`with_impl`](#function-with_impl)
- [`get_or_create_element`](#function-get_or_create_element)
- [`recycle_element`](#function-recycle_element)
- [`can_reuse_element`](#function-can_reuse_element)
- [`create_element`](#function-create_element)
- [`get_data_recycle_key`](#function-get_data_recycle_key)
- [`get_element_recycle_key`](#function-get_element_recycle_key)
- [`default_create_element`](#function-default_create_element)
- [`default_data_recycle_key`](#function-default_data_recycle_key)
- [`default_element_recycle_key`](#function-default_element_recycle_key)

<a id="function-new"></a>

### new

```rust
fn new() -> Rc<Self>
```

A factory with the default behaviour.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L116)

<a id="function-with_impl"></a>

### with_impl

```rust
fn with_impl(behavior: impl TreeDataGridElementFactoryImpl + 'static) -> Rc<Self>
```

A factory whose overridable members are those of `behavior` (a subclass of the reference's
factory).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L122)

<a id="function-get_or_create_element"></a>

### get_or_create_element

```rust
fn get_or_create_element(self: &Self, data: &dyn Any, parent: &Control) -> Ref<Control>
```

Gets a recycled element for `data`, preferring one recycled from `parent`, or creates one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L127)

<a id="function-recycle_element"></a>

### recycle_element

```rust
fn recycle_element(self: &Self, element: &Ref<Control>)
```

Returns `element` to the pool of its recycle key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L153)

<a id="function-can_reuse_element"></a>

### can_reuse_element

```rust
fn can_reuse_element(self: &Self, element: &Control, data: &dyn Any) -> bool
```

Determines whether an existing element can be reused for the supplied data without returning
it to this factory's recycle pool.

This is useful for controls which retain a realized child in the visual tree while changing
its model, avoiding a detach and subsequent style reapplication.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L166)

<a id="function-create_element"></a>

### create_element

```rust
fn create_element(self: &Self, data: &dyn Any) -> Ref<Control>
```

Creates a new element for `data` through the factory's behaviour (`CreateElement`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L171)

<a id="function-get_data_recycle_key"></a>

### get_data_recycle_key

```rust
fn get_data_recycle_key(self: &Self, data: &dyn Any) -> RecycleKey
```

The recycle key of the element that shows `data` (`GetDataRecycleKey`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L176)

<a id="function-get_element_recycle_key"></a>

### get_element_recycle_key

```rust
fn get_element_recycle_key(self: &Self, element: &Control) -> RecycleKey
```

The recycle key of `element` (`GetElementRecycleKey`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L181)

<a id="function-default_create_element"></a>

### default_create_element

```rust
fn default_create_element(self: &Self, data: &dyn Any) -> Ref<Control>
```

The factory's own `CreateElement`: the control for a check box cell, a template cell, an
expander cell, any other cell, a column header or a row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L187)

<a id="function-default_data_recycle_key"></a>

### default_data_recycle_key

```rust
fn default_data_recycle_key(self: &Self, data: &dyn Any) -> RecycleKey
```

The factory's own `GetDataRecycleKey`: the full name of the type of the element
`default_create_element` creates for `data`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L214)

<a id="function-default_element_recycle_key"></a>

### default_element_recycle_key

```rust
fn default_element_recycle_key(self: &Self, element: &Control) -> RecycleKey
```

The factory's own `GetElementRecycleKey`: the full name of the element's type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/tree_data_grid_element_factory.rs#L240)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`TreeModel`](/docs/0.5.0/api/ferroui-treedatagrid-core/accessor/trait-treemodel/)
- `PartialEq`
- `Default`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
