How to use ToolBar.Template () with ToolBar.Excel () in kendo grid
I use toolbar.Template()
and Toolbar.Excel()
, but it Toolbar.Excel()
doesn't show, just toolbar.Template()
show.
.Excel(excel => excel
.FileName("Khu vực.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("ExportArea", "RegistrationManagement")))
//Cài đặt thanh Menu bên trên Grid
.ToolBar(toolbar =>
{
toolbar.Excel().HtmlAttributes(new { @class = "btn btn-danger", style = "float: left" });
toolbar.Template(@<text>
<div class="toolbar" style="float:right">
<a class="btn btn-danger k-grid-add" href="#">
<i class="glyphicon glyphicon-plus"></i> Thêm mới
</a>
<button class="btn btn-danger" data-toggle="modal" data-target="#myModal">
Nhập bằng Excel
</button>
</div>
</text>);
})
I am removing toolbar.Template()
, Toolbar.Excel()
show (following image):
http://i.imgur.com/QR35aQE.png
I keep toolbar.Template (), it doesn't show:
http://i.imgur.com/aONQPzg.png
Help me please! Thank!
P / s: I want a "Nhập bằng Excel" button in front of the "Export to Excel" button.
source to share
For the Excel button to appear on the toolbar, you will need to include the HTML inside the template.
In your case, it would be something like this:
.Excel(excel => excel
.FileName("Khu vực.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("ExportArea", "RegistrationManagement")))
//Cài đặt thanh Menu bên trên Grid
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div class="toolbar" style="float:right">
<a class="btn btn-danger k-grid-add" href="#">
<i class="glyphicon glyphicon-plus"></i> Thêm mới
</a>
<button class="btn btn-danger" data-toggle="modal" data-target="#myModal">
Nhập bằng Excel
</button>
<button class="k-button k-grid-excel btn btn-danger">Export to Excel</button>
</div>
</text>);
})
The next line of HTML you add
<button class="k-button k-grid-excel btn btn-danger">Export to Excel</button>
... basically whatever this line of code is:
toolbar.Excel().HtmlAttributes(new { @class = "btn btn-danger", style = "float: left" });
So just load the page once, once the dashboard template is commented out, see what HTML.Excel () toolbar generates and then copy and paste it inside the template.
source to share