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);
}
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.