Export via TagHelpers

8 posts, 0 answers
  1. Richard
    Richard avatar
    16 posts
    Member since:
    Aug 2011

    Posted 10 Sep 2018 Link to this post

         Didn't see this anywhere in the documentation. How exactly would I set up the toolbar with an Excel export options. I know with HtmlHelpers I would do

    .ToolBar(tools => tools.Excel())

    But i'm not seeing any way to do that with the TagHelpers <excel /> and <toolbar></toolbar>.

    Thanks in advance.

  2. Preslav
    Admin
    Preslav avatar
    591 posts

    Posted 13 Sep 2018 Link to this post

    Hello Richard,

    Based on the syntax from the below article:
    I added this code:

    <toolbar>
        <toolbar-button name="excel"></toolbar-button>
    </toolbar>

    To the "Grid / Tag Helper" demo:
    Now, the Grid is exported to Excel as expected.

    Please, give this a try, and let me know if the above works for you.


    Regards,
    Preslav
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Richard
    Richard avatar
    16 posts
    Member since:
    Aug 2011

    Posted 19 Sep 2018 in reply to Preslav Link to this post

    Preslav,

    Thanks, that works great. It's a bit obscure though, but makes sense in a way. Is there a list somewhere of all built-in grid toolbar functionality that can be added based on naming a toolbar-button properly?

  4. Preslav
    Admin
    Preslav avatar
    591 posts

    Posted 20 Sep 2018 Link to this post

    Hi Richard,

    For the time being, the list is available only in the Kendo UI for jQuery docs:
    I understand that the list should be also placed in the ASP.NET Core documentation. I can confirm that we are doing our best to improve the Core docs as fast as we can.


    Regards,
    Preslav
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Daniel
    Daniel avatar
    23 posts
    Member since:
    Jun 2012

    Posted 08 Jul 2020 Link to this post

    So I am trying to use the attached photo demonstrates. I can confirm that when the export button is clicked the grid sends a read request to the server but it doesn't do anymore than that. I have also tried with the "export to pdf" button which does indeed work. So it must be something to do with the excel itself. 

     

     

  6. Daniel
    Daniel avatar
    23 posts
    Member since:
    Jun 2012

    Posted 08 Jul 2020 in reply to Daniel Link to this post

    I couldn't get the code to format correctly so I am attaching a photo to help with readability and i'll paste the code if you want to copy it.

     

    <kendo-grid name="grid"
                on-data-bound="updateResultCount"
                height="800" style="cursor:pointer"
                resizable="true" reorderable="true"
                detail-template-id="gridRowTemplate"
                auto-bind="true" selectable="single"
                on-change="gridRowChanged">

        <datasource type="DataSourceTagHelperType.Ajax" page-size="pageSize" server-paging="true">
            <transport>
                <read url="@Model.ReadUrl" data="@Model.AdditionalDataFunction" datatype="json" />
            </transport>

        </datasource>
        <toolbar>
            <toolbar-button name="excel"></toolbar-button>
        </toolbar>
        <columns>
            @foreach (var col in Model.Columns)
            {
                <column field="@col.FieldName" title="@col.Title" width="250" min-resizable-width="50"></column>
            }

        </columns>
        <pageable enabled="true" page-size="pageSize" button-count="1"></pageable>
        <scrollable enabled="true" />
        <sortable enabled="true" />


    </kendo-grid>

  7. Preslav
    Admin
    Preslav avatar
    591 posts

    Posted 13 Jul 2020 Link to this post

    Hi Daniel,

    Based on the provided information, I assume that the JSZip library is not included in the app. More information about this is available here - https://docs.telerik.com/aspnet-core/compatibility/export-support#jszip-library

    Could you check if it is included, and if it is not, add it to the solution?

     

    Regards,
    Preslav
    Progress Telerik

  8. Daniel
    Daniel avatar
    23 posts
    Member since:
    Jun 2012

    Posted 20 Jul 2020 in reply to Preslav Link to this post

    Ah, that was probably my issue. I downloaded a custom telerik package from 
    https://www.telerik.com/download/custom-download and had checked "Export to Excel" support so I assumed it had added all the necessary references, thanks.
Back to Top