How to add a toast too a grid button

Hi,

I am using the grid with the crud operations and i was wondering how i could add a toast too a button click 


hSo for instance, once i click delete i would like to show a toast message.. How can this be achieved.. Thanks.

2 Replies 1 reply marked as answer

DI Dingo September 29, 2020 10:12 PM UTC

   
       

           
               
                   
                   
                   

Special Release

                   
                   
                   
                   
                   
                       
                           
                       
                   
               
           
       
   

   
       

           
               
                   
                   
                   
                       
                       
                       
                       
                           
                           
                           
                           
                       
                   
               
           
       
   

@*
       
           
           
           

Contact Helpdesk

       
   
*@





@code{
    public List Orders { get; set; }

    protected override void OnInitialized()
    {
        Orders = Enumerable.Range(1, 75).Select(x => new Order()
        {
            OrderID = 1000 + x,
            CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
            Freight = 2.1 * x,
            OrderDate = DateTime.Now.AddDays(-x),
        }).ToList();
    }

    public class Order
    {
        public int? OrderID { get; set; }
        public string CustomerID { get; set; }
        public DateTime? OrderDate { get; set; }
        public double? Freight { get; set; }
    }
    public class FilterType
    {
        public string id { get; set; }
        public string type { get; set; }
    }
    SfToast ToastObj;
    private string ToastPosition = "Right";
    private List Toast = new List
{
        new ToastModel{ Title = "Warning!", Content="There was a problem with your network connection.", CssClass="e-toast-warning", Icon="e-warning toast-icons" },
        new ToastModel{ Title = "Success!", Content="Your message has been sent successfully.", CssClass="e-toast-success", Icon="e-success toast-icons" },
        new ToastModel{ Title = "Error!", Content="A problem has been occurred while submitting your data.", CssClass="e-toast-danger", Icon="e-error toast-icons" },
        new ToastModel{ Title = "Information!", Content="Please read the comments carefully.", CssClass="e-toast-info", Icon="e-info toast-icons" }
    };
    private async Task InfoBtnOnClick()
    {
        await this.ToastObj.Show(Toast[3]);
    }
    private async Task WarnBtnOnClick()
    {
        await this.ToastObj.Show(Toast[0]);
    }
    private async Task SuccessBtnOnClick()
    {
        await this.ToastObj.Show(Toast[1]);
    }
    private async Task ErrorBtnOnClick()
    {
        await this.ToastObj.Show(Toast[2]);
    }
    private async Task HideBtnOnClick()
    {
        await this.ToastObj.Hide("All");
    }
}


JP Jeevakanth Palaniappan Syncfusion Team September 30, 2020 02:22 PM UTC

Hi Dingo, 

Greetings from Syncfusion support. 

We have validated your query and we suspect that you need to show the toast message while performing CRUD operation. You can achieve your requirement by either using the OnToolbarClick event or OnActionBegin event. In OnToolbarClick event based on the args.Item.Id you can show the corresponding toast message and in OnActionBegin event, based on the args.RequestType, you can show the messages. Please refer the below documentation link for further reference. 


Incase if we misunderstood you query, kindly provide some more information regarding your query. 

Regards, 
Jeevakanth SP. 


Marked as answer
Loader.
Up arrow icon