Category / Section
How to highlight the invalid data in spreadsheet dynamically
1 min read
Description
This knowledge base explains to highlight the invalid data while updating the value for validation applied cells in Spreadsheet.
Solution
It can be achieved by setting the “isHighlightData” property as true in argument of client side ‘actionComplete' event. The validation applied cells are highlighted for mentioned action. For paste action, it is applicable only for paste values only option in Spreadsheet. To enable this paste values only option in spreadsheet “isPasteValuesOnly” property is set as true in client side ‘loadComplete’ event.
[JS]
$("#Spreadsheet").ejSpreadsheet({ loadComplete: "loadComplete", actionComplete: "onActionComplete" });
[RAZOR]
@(Html.EJ().Spreadsheet<object>("Spreadsheet") .ClientSideEvents( events => events.LoadComplete("loadComplete").ActionComplete("onActionComplete") ) )
[ASPX]
<ej:Spreadsheet ID="Spreadsheet" runat="server"> <ClientSideEvents LoadComplete="loadComplete" ActionComplete=”onActionComplete” /> </ej:Spreadsheet>
[JS]
function loadComplete() { // To enable pasteValuesOnly option this.isPasteValuesOnly = true; // Apply datavalidation for A1:A50 range cells this.XLValidate.applyDVRules("A1:A50", ["Between", "0", "60"], "number", true, true); } function onActionComplete(args) { switch (args.reqType) { case "copy-paste": case "auto-fill": args.isHighlightData = true; // To enable isHighlightData option for copy-paste and autofill operation break; } }
The following output is the result of above code example after paste action in spreadsheet.