Grid Toolbar with the Excel Export and Custom Dropdownlist

2 posts, 0 answers
  1. Jon
    Jon avatar
    1 posts
    Member since:
    Oct 2013

    Posted 04 Feb 2015 Link to this post

    How do you add a DropDownlist to Grid Toolbar that is already showing the built in Excel toolbar button.

    @(Html.Kendo().Grid<Reports.ReportRow>()
        .Name("grdReport")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read
                    .Action("AJAX", "Report")
                    .Data("GetReportParms")
            )
        )
        .ToolBar(tools => {
            tools.Excel();
            tools.Template(@<text>
               <div class="toolbar">
                    <label class="category-label" for="category">Version:</label>
                        @(Html.Kendo().DropDownList()
                            .Name("ddlField")
                            .DataTextField("Text")
                            .DataValueField("Value")
                            .AutoBind(true)
                            .Events(e => e.Change("fieldChange"))
                            .DataSource(ds =>
                            {
                                ds.Read("FieldType", "Common");
                            })
                        )
                </div>
            </text>);
        })

    All the examples I can find show either a DropDownList in a Toolbar Template OR the built in Excel toolbar button.  I need both.

    Thanks
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 05 Feb 2015 Link to this post

    Hello Jon,

    The built in commands and the template cannot be used together in the configuration as the template will override them. The solution is to directly include the command mark up in the template. In the current case it would be

    <a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export to Excel</a>

    I wish you a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top