Kendo UI, How to manually call validate() on kendo grid cell

sztepen

Is there a way to call validate() on a cell in kendo-grid without using the editCell() method?

the way to invoke validator recommended by the Telerik team is as follows:

$("myGrid").data("kendoGrid").editable.validatable.validate()

however, no editable object is available if there is no cell open (e.g there is no focused input in the grid), so I have to activate cells one by one to call validate()

I would like to invoke validation on each of the grid cells and run some logic (e.g. addClass())

I succeed if I jquery loop through all td elements in the grid and invoke validate(), like this:

    $(".k-grid-content td").each(function () {
            var cell = $(this);
            grid.editCell(cell);
            if (!grid.editable.validatable.validate()) {
                cell.addClass("cell-invalid");                 
            };
            grid.closeCell(cell);
        });

however this code is not elegant and painfully slow.

What I'm trying to achieve is grid validation on submit.

QUESTION once again: Can I run the kendo validator on each grid cell, without repeatedly entering and leaving the edit mode?

PS: I am using batch edit (incell) mode

jwatts1980

I looked into this a bit deeper, and was unable to find anything in the grid docs that supports this batch validation natively. The grid format, in general, is meant to handle data on a row-by-row basis, which mirrors relational database table / spreadsheet type of data presentation. With that in mind, a typical insert/edit/validate/delete operation is intended to be performed on a single row, or record, at a time.

My answer is: no. You cannot run the Kendo validation without repeatedly entering and leaving the edit mode for each cell that needs validation.

You might be able to if you could dig into the Kendo JS libraries and figure out exactly how the validation is invoked, and create some custom methods to invoke it in a batch manner. Something like that could likely break as soon as the next Kendo update came out.

To make it faster, you may have to come up with a clever way to validate the data as it is entered; or on blur; or as a "background" task using setTimeout; or packaging the data up and sending it back to the server via Ajax then handling return messages somehow.

Good luck!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Kendo UI Grid not populating after call to read

From Dev

How to show € symbol in a kendo grid cell

From Dev

Kendo UI Grid hierarchy

From Dev

How to add Kendo WYSIWYG Editor to a Kendo UI Grid Column?

From Dev

Kendo UI - Tooltip in a grid

From Dev

How do you manually sort a Kendo UI Grid in ASP MVC page?

From Dev

Kendo UI grid update

From Dev

How to show ellipsis for long cell values in kendo ui grid?

From Dev

how to get cell click event in kendo grid

From Dev

how to focus next cell in kendo grid by enter

From Dev

How do I display Kendo Grid inside Kendo Grid cell?

From Dev

How to call a static method in Kendo Grid column

From Dev

Kendo UI Grid alternative

From Dev

Kendo Grid Filterable cell

From Dev

Kendo UI grid filter cell that contains an array

From Dev

How to load manually data in kendo ui grid

From Dev

How to conditionally format Kendo UI grid cell (depending on values) razor

From Dev

Kendo UI Grid hierarchy

From Dev

Kendo UI, How to manually call validate() on kendo grid cell

From Dev

Kendo UI - Tooltip in a grid

From Dev

how to check and change color of cell value in kendo ui grid

From Dev

how to focus next cell in kendo grid by enter

From Dev

Customizing Grid of Kendo UI

From Dev

Kendo UI grid conditionally editable cell

From Dev

How to mark Kendo Grid's cell as edited?

From Dev

Kendo Grid Filterable cell

From Dev

How to change the background of a cell dynamically in a Kendo MVC UI Grid?

From Dev

Kendo UI grid filter cell that contains an array

From Dev

Clickable Cell in Kendo Grid