Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interactive Grid Validation Challenge

SharmaRishuMar 8 2018 — edited Jun 7 2018

Hi Expert,

I am facing challenge in IG. I have below IG with data From Value and To Value. I need to do JavaScript validation here. From Value always should be less then To Value which i am able to get it on column change. I am facing issue when 2nd line From value should be greater than previous row To Value. Please help me if we can achieve this.

pastedImage_1.png

My Sample COde :

//-----------------------------------------------------------

var grid = apex.region("emp").widget().interactiveGrid("getViews", "grid"),

model = grid.model,

record = grid.getSelectedRecords()\[0\];

var current = $(this.triggeringElement).val();

var tes;

$("#scnd").on('change', function() {

    tes = $(scnd).val();

    $(this).data('val', $(this).val());

    if (parseInt(current) \< parseInt(tes)) {

        //  $(this).closest('tr').find('td #scnd').removeClass("highlight");

    } else {

        // alert(model.hasErrors());

        model.forEach(function(r) {

            var id = model.getRecordId(r);

            model.getRecordMetadata(id).fields.TO\_VALUE = {

                message: "you messed up FROM VALUE CURENT"

            };

            //model.metadataChanged(id, "FROM\_VALUE");

            //model.setValidity("error", id, "FROM\_VALUE", "To Value current");

        });

        alert("To Value should be greater then From Value  1st");

    }

});

var prev = $(scnd).data('val');

var validity;

if (typeof prev != 'undefined') {

if (parseInt(current) > parseInt(prev)) {

   alert("Fine");

    alert(model.hasErrors());

    validity = "valid";

} else {

    alert("Pre" + current);

    alert("pre" + prev);

    // $(this).closest('tr').find('td #cComm').addClass("highlight");

    alert("From Value should be less then Last To Value 2nd");

     validity = "error";

// use apex.lang api if you want to localize this message

message = "Commission must be less than 1.5 times the Salary";

    //alert(model.hasErrors());

}

}

Kind Regards,

Harish Sharma

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2018
Added on Mar 8 2018
7 comments
4,349 views