We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to show the custom alert message in Spreadsheet

Platform: jQuery |
Control: ejSpreadSheet |
Published Date: July 31, 2018 |
Last Revised Date: May 22, 2019 |
.NET Framework: 4.5

Description

This knowledge base explains about how to show the custom alert message in 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

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon