File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
src/BootstrapBlazor.Server/Components/Samples Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 1010 <section ignore >
1111 <div >@( (MarkupString )Localizer [" Dom2ImageDesc" ].Value ) </div >
1212 </section >
13- <Button OnClickWithoutRender =" OnExportAsync" Text =" @Localizer[" Dom2ImageButtonText " ]" Icon =" fa-solid fa-image" ></Button >
13+ <Button OnClick =" OnExportAsync" Text =" @Localizer[" Dom2ImageButtonText " ]" Icon =" fa-solid fa-image" class = " mb-3 " ></Button >
1414 <Table TItem =" Foo" Items =" @Items.Take(3)" Id =" table-9527" >
1515 <TableColumns >
1616 <TableColumn @bind-Field =" @context.DateTime" Width =" 180" />
Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ public partial class Dom2Images
1616
1717 [ Inject ]
1818 [ NotNull ]
19- private IHtml2Image ? Html2ImageService { get ; set ; }
19+ private IDom2ImageService ? Dom2ImageService { get ; set ; }
2020
2121 [ Inject ]
2222 [ NotNull ]
23- private IStringLocalizer < Html2Images > ? Localizer { get ; set ; }
23+ private IStringLocalizer < Dom2Images > ? Localizer { get ; set ; }
2424
2525 [ NotNull ]
2626 private List < Foo > ? Items { get ; set ; }
@@ -39,7 +39,9 @@ protected override void OnInitialized()
3939
4040 private async Task OnExportAsync ( )
4141 {
42- _imageData = await Html2ImageService . GetDataAsync ( "#table-9527" ) ;
43- StateHasChanged ( ) ;
42+ _imageData = await Dom2ImageService . GetUrlAsync ( "#table-9527" ) ;
43+
44+ var fileName = $ "table-9527-{ DateTime . Now : HHmmss} ";
45+ await Dom2ImageService . DownloadAsync ( "#table-9527" , fileName ) ;
4446 }
4547}
You can’t perform that action at this time.
0 commit comments