Validation on Grid paste Event

1 Answer 29 Views
Grid
abdul
Top achievements
Rank 2
Iron
abdul asked on 19 Mar 2025, 06:22 PM

Hi,

I have a kendo grid. On copy the records from excel and paste on the kendo grid Paste event is triggered.

Suppose I have pasted 50 records from the excel to the grid. From that 50 records 10 records are invalid and I want to validate and show the error message for each row by row.

Please let me know how we can validate row by row on paste these 50 records from excel to kendo grid.

Events(events => events.Paste("onPaste"))
function onPaste(e) {

}

1 Answer, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 24 Mar 2025, 08:58 AM

Hi Abdul,

Thank you for the details provided.

In the Paste event, the rows can be retrieved from the event handler, allowing access to the modified cells. These cells can then be validated, and if any contain invalid data, the jQuery text method can be used to display a validation message within the respective cell.

Below is an example of the implementation:

function onPaste(e) {
    var prevent = false;
    var dirty = $.grep(e.items, function (item) {
        return item.dirty
    });

    dirty.forEach((item) => {
        let row = $(`[data-uid="${item.uid}"]`);

        if (!kendo.parseFloat(item.Freight)) {
            row.find("td:eq(1)").text("incorrect");
        }
    });
}

Furthermore, I prepared a sample application where the suggested modifications could be tested.

I hope this information was helpfuls.

Kind Regards,
Ivaylo
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
Grid
Asked by
abdul
Top achievements
Rank 2
Iron
Answers by
Ivaylo
Telerik team
Share this question
or