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

DataGrid and TreeList - Toolbar customization enhancement #19076

Closed
NickMitrokhin opened this issue Sep 6, 2021 · 9 comments
Closed

DataGrid and TreeList - Toolbar customization enhancement #19076

NickMitrokhin opened this issue Sep 6, 2021 · 9 comments

Comments

@NickMitrokhin
Copy link
Contributor

The Problem

Currently, the only way to customize toolbar in DataGrid/TreeList is to use onToolbarPreparing event. You cannot use this method to change settings of buttons once toolbar is created. Direct DOM mutations are not recommended when you use React, Angular, and Vue frameworks.

The Proposed Solution

We plan to add a new toolbar option that allows you to customize toolbar items the same way as the Toolbar. Each toolbar item can be specified as an object with the same number of properties as an item of a stand-alone toolbar or a string name from the following list: 'addRowButton', 'applyFilterButton','columnChooserButton', 'exportButton', 'groupPanel', 'revertButton', 'saveButton', 'searchPanel'.
Note that the option will allow you to customize only toolbar items, not the entire toolbar. If you want to customize the toolbar, use the onToolbarPreparing event.

The following code snippet shows how to specify items:

jQuery

$('#container').dxDataGrid({
    ...
    toolbar: {
        items: [
            {
                location: "before",
                widget: "dxButton",
                options: {
                    text: "My button",
                    width: 120,
                    onClick: function(e) {
                        // execute your code when the button is clicked
                    }
                }
            },
            'columnChooserButton'
        ]
    },
    ...   
})

Angular

<dx-data-grid ...>
    ...
    <dxo-toolbar>
        <dxi-item location="before">
            <dx-button
                text="My button"
                width="120"
                (onClick)="onClickHandler($event)">
            </dx-button>        
        </dxi-item>
        <dxi-item name="columnChooserButton"></dxi-item>
    </dxo-toolbar>
    ...   
</dx-data-grid>

React

<DataGrid ...>
    ...
    <Toolbar>
        <Item location='before'>
            <Button
              text='My button'
              width='120'
              onClick={this.onClickHandler} />
        </Item>
        <Item name='columnChooserButton' />
    </Toolbar>        
    ...
</DataGrid>

Vue

<DxDataGrid ...>
    ...
    <DxToolbar>
        <DxItem location="before">
            <DxButton
                text="My button"
                width="120"
                @click="onClickHandler"
            />
        </DxItem>
        <DxItem
            name="columnChooserButton"
        />
    </DxToolbar>        
    ...
</DxDataGrid>

If you need a better solution to customize the whole toolbar, you can share your usage scenario in the comments and we will consider them for future customization API enhancements.

Try It

Live Sandbox

jQuery
React
Vue

We need Your Feedback

Take a Quick Poll

Do the new toolbar option meet your needs?

@jakehockey10
Copy link

Looking forward to this! Thank you!

@softboy99
Copy link

+1

@Lonli-Lokli
Copy link

Just FYI, in React demo

  1. onToolbarPreparing={this.onToolbarPreparing} exists but handler is not defined
  2. App is broken on Collapse All button click

@NickMitrokhin
Copy link
Contributor Author

Thank you for pointing out these issues. We updated the example.

@reezan
Copy link

reezan commented Oct 22, 2021

is this available on 21.6?

@NickMitrokhin
Copy link
Contributor Author

Hi @reezan,

This feature will be available only in v21.2.

@alasoft
Copy link

alasoft commented Dec 14, 2021

I have a detected a possible problem with new dxDataGrid toolbar implementation, can I comment that here ?

Robert

@onebalaban
Copy link
Contributor

@alasoft sure

@Alyar666
Copy link
Contributor

Alyar666 commented Jul 7, 2022

These features are now available in the v21.2 release. I'm closing this thread. In the case of bugs or questions, feel free to create a new ticket in our Support Center.

@Alyar666 Alyar666 closed this as completed Jul 7, 2022
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

9 participants