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

Custom toolbar command

4 Answers 308 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Roth
Top achievements
Rank 1
Brian Roth asked on 18 Jul 2012, 10:38 PM
Hello,

I'm trying to set up a custom toolbar command in an MVC grid.  Is there an example of how to do this?  I see the options in the type-ahead and set up my command like this:

commands.Custom().Text("Clear Filters").Name("clear-filters");

I'd like to be able to run some jquery logic when this button is clicked to clear out all the current filters for the grid.  I've got the function written to clear the filters, I just don't know how to hook that up to the button to kick it off.

Thanks for the help!

Regards,
Brian

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 19 Jul 2012, 10:32 AM
Hello Brian,

You can set a custom CSS class to the button by using HtmlAttributes(). Then use this class to assign a click handler with jQuery. If you need further assistance on any of these steps, please submit a support ticket.

Kind regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brian Roth
Top achievements
Rank 1
answered on 19 Jul 2012, 09:47 PM
Hi Dimo,

I tried this and it didn't work for me.  Here's the error I got:

CS1061: 'Kendo.Mvc.UI.Fluent.GridToolBarCustomCommandBuilder<MyModel>' does not contain a definition for 'HtmlAttributes' and no extension method 'HtmlAttributes' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.GridToolBarCustomCommandBuilder<MyModel>' could be found (are you missing a using directive or an assembly reference?)

My code looks like this now:
commands.Custom().Text("Clear Filters").Name("clear-filters").HtmlAttributes(new { onclick = "mygrid.clearFilters(event, this)" });

I didn't get any type-ahead in the Razor page for the HtmlAttributes method.  Is this something that isn't supported yet in the Kendo MVC stuff?

Thanks,
Brian
0
Dimo
Telerik team
answered on 20 Jul 2012, 07:41 AM
Hi Brian,

I suspect that you are using the Q2 beta. Please upgrade to the official release, which has this feature available.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brian Roth
Top achievements
Rank 1
answered on 20 Jul 2012, 09:35 PM
Thanks!  I guess when I upgraded to the final release there were still some references pointing to the beta.

Regards,
Brian
Tags
Grid
Asked by
Brian Roth
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Brian Roth
Top achievements
Rank 1
Share this question
or