Articles in this section
Category / Section

How to show the custom alert message in JavaScript Spreadsheet?

2 mins read

Description

This knowledge base explains about how to show the custom alert message in JavaScript Spreadsheet.

Solution

In the below code example, we have provided the custom alert message for ‘LockCell’ alert.

 

JavaScript

$(function () {
    $("#Spreadsheet").ejSpreadsheet({
        sheets: [{
            // window.defaultData from xljsondata file.
            dataSource: window.defaultData
        }],
        loadComplete: "onLoadComplete",
    });
});
 
function onLoadComplete(args) {
    //Lock the cells that you want. Here we have locked the cells A1:H11 to prevent editing.
    this.lockCells("A1:H11", false);
    this.protectSheet(true);
}
 
//By default, Spreadsheet rendered in "en-US" locale. You can customize the alert message based on locale.
ej.Spreadsheet.Locale["en-US"] = {
    // This is for lock cell property
    LockAlert: "Here your custom alert message!"
}

 

MVC

CSHTML

@{Html.EJ().Spreadsheet<object>("Spreadsheet")
    .Sheets(sheet =>
    {
        sheet.Datasource((IEnumerable<object>)ViewBag.Datasource).Add();
    }).ClientSideEvents(events => events.LoadComplete("onLoadComplete"))
    .Render();
}
<script>
    function onLoadComplete(args) {
        //Lock the cells that you want. Here we have locked the cells A1:H11 to prevent editing.
        this.lockCells("A1:H11", false);
        this.protectSheet(true);
    }
 
    //By default, Spreadsheet rendered in "en-US" locale. You can customize the alert message based on locale.
    ej.Spreadsheet.Locale["en-US"] = {
        // This is for lock cell property
        LockAlert: "Here your custom alert message!"
    }
</script>

 

Controller

public ActionResult Index()
{
    //ItemData is a class which has list collection.
    var DataSource = ItemData.GetAllItemDetails.ToList();
    ViewBag.Datasource = DataSource;
    return View();
}

 

ASP .NET

ASPX

<ej:Spreadsheet ID="Spreadsheet" runat="server">
    <Sheets>
        <ej:Sheet></ej:Sheet>
    </Sheets>
    <ClientSideEvents LoadComplete="onLoadComplete" />
</ej:Spreadsheet>
<script>
    function onLoadComplete(args) {
        //Lock the cells that you want. Here we have locked the cells A1:H11 to prevent editing.
        this.lockCells("A1:H11", false);
        this.protectSheet(true);
    }
 
    //By default, Spreadsheet rendered in "en-US" locale. You can customize the alert message based on locale.
    ej.Spreadsheet.Locale["en-US"] = {
        // This is for lock cell property
        LockAlert: "Here your custom alert message!"
    }
</script>

 

ASPX.CS

protected void Page_Load(object sender, EventArgs e)
{
    //ItemData is a class which has list collection.
    var dataSource = ItemData.GetAllItemDetails.ToList();
    this.Spreadsheet.Sheets.Add(new Syncfusion.JavaScript.Models.Sheet()
    {
        Datasource = dataSource
    });
}

 

The localization text for Spreadsheet can be found in the below demo link.

https://js.syncfusion.com/demos/web/#!/bootstrap/spreadsheet/localization

 

The following output is displayed as the result of adding the custom alert message for ‘LockCell’ alert.

 

spreadsheet lock cell alert  sample preview

 

Conclusion

I hope you enjoyed learning about how to show the custom alert message in JavaScript Spreadsheet.

You can refer to our JavaScript Spreadsheet feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. . You can also explore our JavaScript Spreadsheet example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied