Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
515
Regarding custom validation when one field is dependent on other.
posted

Hello everyone,

So,  I have created a grid and populated it with data. So i have two doubts. 

1) how to target a particular field for custom validation. I have used it here but i couldnt understand how its getting the element.

2) suppose i have two columns marks and image. So i want to apply a validation that if marks is greater than 60 and less than 100 then image field is mandatory else it is optional . can you help me like how to do that.

Heres my code,

<script>
$(function () {
$("#grid").igGrid({
primaryKey: "id",
renderCheckboxes: true,
autoGenerateColumns: false,
updateUrl: "/Student/put/",
width: "100%",

columns: [
{ headerText: "Student ID", key: "id", dataType: "number", width: "15%" },
{ headerText: "Student Name", key: "name", dataType: "string", width: "30%" },
{ headerText: "Marks", key: "marks", dataType: "number", width: "30%" },
{
headerText: "Image",
key: "imagepath",
dataType: "string",
width: "15%",
template: "<img src='${imagepath}' width='50' height='50' />"
},
{ headerText: "Subject", key: "subject", dataType: "string", width: "15%" }
],
dataSourceUrl: "/Student/Data12",
dataSource: "/Student/Data",


features: [
{
name: "Selection",
mode: "row",
multipleSelection: true
},
{
name: "RowSelectors",
enableCheckBoxes: true,
enableRowNumbering: true
},
{
name: "GroupBy"
},
{
name :"Paging",
type:"local",
pageSize : 7
},

{
name: "Filtering",
columnSettings: [
{
columnKey: "selectColumn",
allowFiltering: false
}
]
},
{
name: "Sorting",
type: "remote",
// sortUrlKey: 'sort',
// sortUrlKeyAscValue: 'asc',
// sortUrlKeyDescValue: 'desc'
},
{
name: "Updating",
enableAddRow: true,
editMode: "row",
validation: true,
enableDeleteRow: true,
rowAdded: function (evt, ui) {
// Custom logic to execute when a row is added
console.log("Event arguments (ui):", ui);
console.log("Row data:", ui.rowId);
console.log(typeof (ui.values));
},
columnSettings: [
{
columnKey: "id",
readonly: true

},
{
columnKey: "name",
editorType: "text",
validation: true,
editorOptions: {

validatorOptions:
{
required: {
errorMessage: "You must enter a value to submit."

},
custom: function(ui,evt){
var validator = $("#grid").igGridUpdating("editorForKey", "name").data("igValidator").element;
console.log(validator);
if (ui == "rohit")
$(validator).igValidator("option", "errorMessage", "cant enter name rohit");
return false;
return true;

}

}
}
}
]
}
]
});
var editor = $("#grid").igGridUpdating("editorForKey", "id");
alert(editor);

$("#savechanges").on("click", function () {
alert("Save button clicked");
// Save changes when the button is clicked
$("#grid").igGrid("saveChanges");
});
});

</script>

  • 0
    Offline posted

    All of our Chanakyapuri escorts are having a great personality and are having all the qualities which a man wants in their *** partner. Chanakyapuri Escorts of our agency are dedicated towards their Chanakyapuri Escort Service work and are very elegant in means of ***. We have various category of female escorts and VIP escort girls like Female Models, Celebrities, Office Secretary, Housewife, College Girl, Airhostess, Company Secretary, Sales Girls, Russian Escorts etc.

  • 0
    Offline posted

    Everyone is chasing their goal to attain satisfaction and happiness. But it is also necessary to unwind your stress every so often so you stay revitalized for always. And nothing can be as satisfying as hiring Bhopal Call Girls for enjoying your *** desires and saying bye to your stress.

  • 0
    Offline posted

    Thanks for the Information. KNOW MORE : Rc king mass gainer

  • 0
    Offline posted

    Independent Escorts in Friends Colony are renowned for their stunning beauty, natural sensuality and dedication to satisfying each client's specific needs. Whether its carnal pleasure you seek or simply need someone to share a glass of wine and listen to your troubles with, our girls can meet every desire with discretion and ease.

  • 0
    Offline posted in reply to Georgi Anastasov

    In vex 3, you must run, leap over obstacles, and navigate perilous levels! Stickman vex returns with even more exhilarating and challenging action.