Referenting object in Toast

    <SfToast ID="tChartToast" @ref="tChartToast" Width="230px" ExtendedTimeout="0" Timeout="@templateToastTimeout" >
        <ToastPosition X="Center" Y="Bottom"></ToastPosition>
        <ToastTemplates>
            <Template >
                <div style="width:100%; height:100%">
                    <Components.Unified.TChart @ref="tChart"></Components.Unified.TChart>
                </div>
            </Template>
        </ToastTemplates>
    </SfToast>

Hello dear support. I would like to reference an object in the template, which have to be always ready to work with. Is there a way to achive this ?
( since tChart  at the moment shows NULL )

3 Replies

IS Indrajith Srinivasan Syncfusion Team December 10, 2020 06:51 AM UTC

Hi Yordan, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query. You can initialize the page object in the code section, to get the ref of the corresponding page. Check the below code blocks for reference. 
 
Code blocks:  
 
Index.razor 
 
 
@using Syncfusion.Blazor.Notifications 
@using Syncfusion.Blazor.Charts 
 
<button class="e-btn" @onclick="@Show">Chart Refrence</button> 
 
<SfToast ID="tChartToast" @ref="tChartToast" Width="230px" ExtendedTimeout="0" Timeout=4000> 
    <ToastPosition X="Center" Y="Bottom"></ToastPosition> 
    <ToastTemplates> 
        <Template> 
            <div style="width:100%; height:100%"> 
                <ChartComponent @ref="tChart"></ChartComponent> 
            </div> 
        </Template> 
    </ToastTemplates> 
</SfToast> 
 
@code { 
    ChartComponent tChart = new ChartComponent(); 
    SfToast tChartToast; 
 
    public async Task Show() 
    { 
        this.tChartToast.Show(); 
    } 
} 
 
 
ChartComponent.razor 
 
 
@using Syncfusion.Blazor.Charts 
 
<SfChart></SfChart> 
 
 
Please let us know if the solution helps, 
 
Regards, 
Indrajith


YO Yordan December 10, 2020 10:51 PM UTC

Works great !
Thank You dear support !


IS Indrajith Srinivasan Syncfusion Team December 11, 2020 04:08 AM UTC

Hi Yordan, 
 
Welcome, 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Indrajith 


Loader.
Up arrow icon