This is a migrated thread and some comments may be shown as answers.

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

1 Answer 1219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anand Vardhan
Top achievements
Rank 1
Anand Vardhan asked on 14 Sep 2016, 07:03 PM
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) {
                                 debugger;
                                 var columnIndex = 0;
                                 var grid = $("#bAPLMappingGrid").data("kendoGrid");
 
                                 for (columnIndex; columnIndex < grid.columns.length; columnIndex++) {
                                     if (grid.columns[columnIndex].field == "EndDate") {
                                         break;
                                     }
                                 }
                                 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 }
                 }
             }

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 16 Sep 2016, 12:56 PM
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);
alert(dataItem.EndDate);

Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Anand Vardhan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or