How to get different column values of a row in grid in custom validator while doing inline editing?

2 posts, 0 answers
  1. Anand Vardhan
    Anand Vardhan avatar
    2 posts
    Member since:
    Sep 2016

    Posted 14 Sep 2016 Link to this post

    I am writing this below. I am able to get the StartDate field value in my case, but I am not able to get EndDate field value. It is coming as undefined. Please help.

    model: {
                     id: "BusinessAreaDivisionMappingId",
                     fields: {
                         BusinessAreaDivisionMappingId: { type: "number", editable:false,     nullable: false },
                         StartDate: {
                             type: "date",
                             required: true,
                             validation: {
                                 required: true,
                                 dateComparisonValidation: function (element) {
                                     var columnIndex = 0;
                                     var grid = $("#bAPLMappingGrid").data("kendoGrid");
                                     for (columnIndex; columnIndex < grid.columns.length; columnIndex++) {
                                         if (grid.columns[columnIndex].field == "EndDate") {
                                     var StartDate = new Date($(element).data("kendoDatePicker").value());
                                     var EndDate = new Date($(element).closest("tr").find("td:eq(" + columnIndex + ")").text());
                                     element.attr("data-dateComparisonValidation-msg", "Start Date Cannot be more than End Date");
                                     if (StartDate && EndDate)
                                         return (StartDate >= EndDate);
                                     return true;
                         EndDate: { type: "date" },
                         IsDeleted: { type: "boolean", editable: false, nullable: true }
  2. Konstantin Dikov
    Konstantin Dikov avatar
    2447 posts

    Posted 16 Sep 2016 Link to this post

    Hi Anand,

    You can get reference to the TR element and then, using the dataItem method of the Grid, get reference to the data item from which you can retrieve the other field values:
    var grid = $("#bAPLMappingGrid").data("kendoGrid");
    var row = input.closest("TR");
    var dataItem = grid.dataItem(row);

    Hope this helps.

    Konstantin Dikov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top