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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Essential JS2

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

Custom validation function for full column

Thread ID:

Created:

Updated:

Platform:

Replies:

147621 Sep 17,2019 02:50 PM UTC Sep 20,2019 01:56 PM UTC jQuery 3
loading
Tags: ejSpreadSheet
Todd Hoyle
Asked On September 17, 2019 02:50 PM UTC

How can I apply a custom validation function for a full column in javascript spreadsheet.

I am not quite sure how to properly format the excelObj.XLValidate.applyDVRules

Thank you.


Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On September 18, 2019 07:20 AM UTC

Hi Todd, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your requirement and you can apply validation to entire column by specifying range in applyDVRules method in Spreadsheet. Please check the below link for more details about applyDVRules method, 
 
 
 
 
Could you please check the above details and get back to us if you need any further assistance on this? 
 
Regards, 
Vinoth Kumar S 


Todd Hoyle
Replied On September 18, 2019 02:08 PM UTC

Thank you for your reply.
I had already read those articles and samples.

I don't see how to define an entire row as having a validation rule, just ranges. In the demo, it is only applying to rows 1-15. If I add a new row on 16 it doesn't have the validation. Do I need to place event handlers that extend validation to new rows as they are added? versus stating this entire column has this validation?
If so what might that look like? 

I also only see the built in validations being shown here. Not a custom one. For example I need to validate one cell based on content in another cell. I have a function written to do the validation, I am just not sure how to pass it into the applyDVRules function.

Thanks
Todd


Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On September 20, 2019 01:56 PM UTC

Hi Todd, 
 
Query #1: I don't see how to define an entire row as having a validation rule 
 
We would like to let you know that your requirement can be achieved by using selectRow method. Please find the below code snippet, 
 
Code Snippet 
function fun() { 
    var xlObj = $("#Spreadsheet").ejSpreadsheet("instance"); 
    xlObj.XLValidate.applyDVRules(xlObj.XLSelection.selectRow(1), ["Between", "15", "20"], "number", true, true); 
} 
 
Query #2:  I add a new row on 16, the validation should be maintained 
 
We have checked your requirement and as per our current behavior, when you have inserted the row between the validation applied range then it will be maintained. We have achieved your requirement in the actionComplete event. Please find the below code snippet, 
 
Code Snippet 
function actionComplete(args) { 
    if (args.action == "insertRow") { 
        var xlObj = $("#Spreadsheet").ejSpreadsheet("instance"), range, splitData, rule, rng, options, fillRange; 
        rule = xlObj.XLEdit.getPropertyValue(args.startCell.rowIndex - 1, args.startCell.colIndex, "rule", args.sheetIndex); 
        splitData = rule.customVal.split("_"); 
        rng = this.getRangeIndices((splitData[1] === "list") ? splitData[3] : splitData[6]); 
        range = this.getAlphaRange(rng[0], rng[1], rng[2], rng[3]); 
        fillRange = this.getAlphaRange(rng[2] + 1, rng[1], rng[2] + 1, rng[3]); 
        xlObj.XLSelection.selectRange(fillRange); 
        options = { dataRange: range, direction: "down", fillRange: fillRange, fillType: ej.Spreadsheet.AutoFillOptions.CopyCells } 
        xlObj.XLDragFill.autoFill(options); 
        xlObj.clearContents(fillRange); 
    } 
 
} 
function btnClick() { 
    var xlObj = $("#Spreadsheet").ejSpreadsheet("instance"); 
    xlObj.insertEntireRow(15, 16); 
} 
 
 
Please find the below sample link, 
 
Query 3: Need to validate one cell based on content in another cell. I have a function written to do the validation, I am just not sure how to pass it into the applyDVRules function. 
 
Could you please confirm whether you need formula based or cell based validation and its use case scenario? 
 
Regards, 
Vinoth Kumar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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