This is a migrated thread and some comments may be shown as answers.

Grid ToolBar for Vuejs

7 Answers 406 Views
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 27 Nov 2018, 01:26 PM

Is it possible to bind buttons created in a ToolbarTemplate for a grid in vuejs ?

The purpose is to enable/disable button if a row is selected or not

7 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 29 Nov 2018, 08:58 AM
Hello David,

There is an existing demo that demonstrates a similar scenario to the one described - binding a button click event from ToolBar template. The example is available here:


Based on the above example, you could try subscribing to the Grid's change event and retrieve the currently selected item through the select() method. Then, based on a condition, query the grid.wrapper element for the respective button and disable it.

Regards,
Dimitar
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rudy
Top achievements
Rank 1
answered on 29 Jan 2019, 12:41 AM
Did you ever figure out how to do this? I have been using this example for reference and still cannot get it to work properly. 
0
Dimitar
Telerik team
answered on 29 Jan 2019, 02:49 PM
Hello Rudy,

Could you elaborate a bit more on what is the exact issue with the implementation so that I can investigate it further?

Regards,
Dimitar
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rudy
Top achievements
Rank 1
answered on 29 Jan 2019, 04:19 PM

I need to add a button in the toolbar that acts the same way as a "Create" button would. The reason I am doing this is because I want to send the user to a form that I have created in a different component, and not use the built in popup or inline edit mode. The example uses a refresh button which should be the same for any other type of button. However I simply cannot get the click event. I have set up my project the exact same way as the example and used the code from the example and still cannot get the click event for the button.

0
Dimitar
Telerik team
answered on 31 Jan 2019, 12:30 PM
Hello Rudy,

On the following StackBlitz example, you can find a simple Grid implementation that has a custom button integrated inside the toolbar component. This is achieved as follows:
// View
<kendo-grid-toolbar class="k-grid-toolbar">
  <button type="button" class="k-button" v-on:click="createRecord">Create Custom</button>
</kendo-grid-toolbar>
 
// Handler
methods: {
  createRecord: function() {
    alert("custom button clicked");
  },     
}

Regards,
Dimitar
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
Veteran
answered on 15 Nov 2020, 05:32 PM

Hello Dimitar,

thanks for example.

I'm missing the new empty record in the grid. Can I use a command inside the method?

Regards,

Michael

0
Petar
Telerik team
answered on 17 Nov 2020, 01:37 PM

Hello Michael,

If the targeted functionality is to have the "Add new record" button added to the custom Toolbar of the Grid, here is a Stackblitz example demonstrating how we can achieve this functionality. 

To implement the custom Toolbar, the following code is used:

customToolbarTemplate: function() {
  var templateHtml =
    '<a role="button" class="k-button k-button-icontext k-grid-add" href="\\#">' +
    '<span class="k-icon k-i-plus"></span>Add new record' +
    "</a>" +
    "<span>" 

  return kendo.template(templateHtml);
}

The code in yellow adds the "Add new record" button. 

The customToolbarTemplate is assigned to the Grid, with the following configuration.

:toolbar="customToolbarTemplate"

I hope the above answers your question. 

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
David
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Rudy
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Veteran
Petar
Telerik team
Share this question
or