Articles in this section
Category / Section

How to restrict paste to Paste Values only in JavaScript Spreadsheet?

2 mins read

Description

This knowledge base explains how to change the default paste option behavior in JavaScript Spreadsheet.


Solution

It can be achievable by setting the “isPasteValuesOnly” property as true in client side ‘loadComplete’ event. It restricts the paste operation to paste values only in the cells by using the “isPasteValuesOnly” option in Spreadsheet.

 

[JS]

 

$("#Spreadsheet").ejSpreadsheet({
    sheets: [{
    // window.defaultData from http://js.syncfusion.com/demos/web/scripts/xljsondata.min.js file.
    dataSource: window.defaultData
    }],
    loadComplete: "loadComplete"
});

 

[RAZOR]

 

@(Html.EJ().Spreadsheet<object>("Spreadsheet")
    .Sheets(sheets =>
    {
        <!-- you can define datasource at server side -->
        sheets.Datasource((IEnumerable)ViewBag.DataSource).Add();
    })
    .ClientSideEvents(
        events => events.LoadComplete("loadComplete")
    )
)

 

[ASPX]

 

<ej:Spreadsheet ID="Spreadsheet" runat="server">
    <Sheets>
        <ej:Sheet></ej:Sheet><!-- you can define datasource at server side -->
    </Sheets>
    <ClientSideEvents LoadComplete="loadComplete" />
</ej:Spreadsheet>

 

[JS]

 

function loadComplete(args) {
    if (!this.isImport) {
        // To enable pasteValuesOnly option
        this.isPasteValuesOnly = true;
    }
}

 

The below screenshot represents the output of the above code example, after performing the paste operation in Spreadsheet.

 

JS Spreadsheet paste operation sample preview


Conclusion

I hope you enjoyed learning about how to restrict paste the Paste values 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 ASP.NET PDF example to understand how to create and manipulate data.

For current customers, you can check out our JavaScript controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our 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 forums, Direct-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  to leave a comment
Access denied
Access denied