【问题标题】:How to change Kendo Excel Button Content Text如何更改 Kendo Excel 按钮内容文本
【发布时间】:2015-03-22 07:33:11
【问题描述】:

我有一个具有 Excel 导出功能的剑道网格。它会生成一个“导出到 Excel”文本按钮,我想更改它的文本,例如“发送到 Excel”。

 @(Html.Kendo().Grid(Model).ToList())
.Name("Grid")

.Columns(columns =>
{
    //columns.Bound(p => p.BirimAd).Title("Birim").Width(500);
    columns.Bound(p => p.SehirAd).Title("Şehir").HtmlAttributes(new { style = "text-align:center" }).Width(200);
    columns.Bound(p => p.Value).Title("Value").HtmlAttributes(new { style = "text-align:center" }).Width(200);
    //columns.Bound(p => p.Avg).Title("Avg").HtmlAttributes(new { style = "text-align:center" }).Width(200);
})
  .ToolBar(tools => tools.Excel())

.Sortable()

.Excel(excel => excel
    .FileName("Rapor.xlsx")
    .Filterable(true)
    .ProxyURL(Url.Action("Excel_Export_Save", "Report"))
)

.ColumnMenu()
.DataSource(dataSource => dataSource
    .Ajax()

.Read(read => read.Action("Excel_Export_Read", "Report"))
)
    )

excel 按钮就是这样生成的:

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

我正在尝试这个 CSS:

 <style>

     .k-button k-button-icontext k-grid-excel
     {
         content:"Send to Excel";
     }
     .k-icon k-i-excel
     {
         content:"Send to Excel"
     }

 </style>

但它看起来像相同的文本。怎么改?

【问题讨论】:

    标签: css kendo-ui kendo-grid


    【解决方案1】:

    使用自定义命令并通过 javascript api 调用导出

    剃须刀:

    .ToolBar(tools => tools.Custom("Export").Text("Send to Excel").Click("exportExcel"))
    

    Javascript:

    function exportExcel() {
        var grid = $("#grid").data("kendoGrid");
        grid.saveAsExcel();
    });
    

    【讨论】:

      【解决方案2】:

      我覆盖了绑定事件中的文本:

      @(Html.Kendo().Grid(Model)
        Events(eventes => {
           eventes.DataBound("bound"); 
        })
        .ToolBar(tools => tools.Excel())
        .Excel(excel => excel
              .FileName("Test.xlsx")
              .Filterable(true)
              .ProxyURL(Url.Action("TestExcel", "Export"))
          )
      

      然后在绑定事件中:

      <script>
      function bound(e) {
         ...
         $(".k-grid-excel").html('<span class="k-icon k-i-excel"></span>Exportar a Excel');
      }
      

      【讨论】:

        【解决方案3】:

        我认为 API 多年来发生了变化,下面的代码在 2019 年适合我

          .ToolBar(tb => tb.Excel().Text("Any Text") )
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-05-16
          • 1970-01-01
          • 2020-05-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多