How to export grid to excel using custom adapter

I am trying to export the data inside the grid to Excel by sending the handle value from the external layout.

Grid values ​​are updated via custom adapter, no response when sending handle values ​​to export grid values ​​to excel.

Also trying to export by creating an external button doesn't work.

Please tell me how to export grid list to excel using custom adapter



<SfButton CssClass="e-flat" IsToggle="true" IsPrimary="true" Content="TEST" @onclick="onToggleClickkk"></SfButton>

    <SfGrid @ref="_gridObj" TValue="MediaFile" ShowColumnMenu="true" AllowReordering="true" AllowFiltering="@Filtering" AllowPaging="true" AllowResizing="true" AllowSorting="true" Height="250px" EnableVirtualMaskRow="true" AllowExcelExport="true" AllowPdfExport="true" ContextMenuItems="@(new List<ContextMenuItemModel>() {new ContextMenuItemModel {Text = "파일 다운로드", Target = ".e-content", Id = "FileDownload"}})" Query="@Qry">

        <SfDataManager @ref="_gridObjManager" Adaptor="Adaptors.CustomAdaptor" AdaptorInstance="@typeof(BlazorBoilerplate.Shared.Models.Hyena.Project.MediaFileAdapter)">

        </SfDataManager>

        <GridEvents TValue="MediaFile" RowSelected="OnRowSelected" ContextMenuItemClicked="ContextMenuItemClickedHandler"></GridEvents> @*OnActionComplete="ActionCompletedHandler"*@

        <GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Single" EnableToggle="false" CheckboxMode="CheckboxSelectionType.ResetOnRowClick"></GridSelectionSettings>

        <GridPageSettings PageSize="@PageSize"></GridPageSettings>

        <GridColumns>


@code {


    private long _projectId;

    SfGrid<MediaFile> _gridObj { get; set; }

    SfDataManager _gridObjManager { get; set; }

    private PagedListRequestObj _pagedListRequestObj;

    private bool viewTrue { get; set; } = true;


    public Query Qry; // = new Query().Where("PagedListRequestObj", "equal", new PagedListRequestObj());


    protected override async Task OnInitializedAsync()

    {

        _port = _configuration["Hyena.Search:Port"];

        //등록

        _paramAnalysisPage.ProjectChangeEvent += RefreshGridEventHandler;

        _paramAnalysisPage.OnChangeGrid += RefreshSelectedGrid;

        _paramAnalysisPage.QueryChangeEvent += RefreshGridEventHandler;


        if (_paramAnalysisPage != null)

        {

            //등록

            _paramAnalysisPage.ExcelExportEvent += HandleExcelExportEvent;

            _paramAnalysisPage.PrintEvent += HandlePrintEvent;

        }

        _gridObj = new();

        _gridObjManager = new();

    }


    private void HandleExcelExportEvent()

    {

        _gridObj.ExcelExport();

        //ExcelExportProperties exportProperties = new ExcelExportProperties();

        //exportProperties.IncludeTemplateColumn = true;

        //string nameTemp = _paramAnalysisPage.ProjectId.ToString();

        //exportProperties.FileName = "HyenaProject[" + nameTemp + "]_File_List.xlsx";

        //// _gridObj.AutoFitColumnsAsync();

        //_gridObj.ExcelExport(exportProperties).ConfigureAwait(false);


    }

    public void onToggleClickkk()

    {

        ExcelExportProperties exportProperties = new ExcelExportProperties();

        exportProperties.IncludeTemplateColumn = true;

        string nameTemp = _paramAnalysisPage.ProjectId.ToString();

        exportProperties.FileName = "HyenaProject[" + nameTemp + "]_File_List.xlsx";

        // _gridObj.AutoFitColumnsAsync();

        _gridObj.ExcelExport(exportProperties);

    }


3 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team November 24, 2021 10:34 AM UTC

Hi ArcBlue, 

Greetings from Syncfusion support. 

We have validated your query and we have tried to reproduce the reported problem in a custom adaptor sample but unfortunately we are unable to reproduce it. We have attached the video demo and the validated sample for your reference. 


If you are still facing the reported problem then kindly share us the below details, 

  1. Share us the Syncfusion NuGet version details.
  2. Share us the exact problem you are facing.
  3. Have you faced any exception during the excel export?
  4. Share us the video demo showing the problem you are facing
  5. Kindly share us the issue reproducing sample or reproduce the reported problem in the above provided sample.

The above requested details will be helpful for us to validate your query and to provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 


Marked as answer

UN Unknown replied to Jeevakanth Palaniappan November 26, 2021 02:23 AM UTC

I checked the example code above and came up with a solution hint.

I solved it by adding gird.TotalItemCount to the query. Thank you for your kindness.



JP Jeevakanth Palaniappan Syncfusion Team November 26, 2021 03:48 AM UTC

Hi ArcBlue, 

We are glad that you have achieved your solution. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon