How to conditionally click a checkbox in telerik grid based on another column in the grid

Viewed 14

Currently I am using Telerik MVC and Ajax javascript trying to click a checkbox after checking if the comment column has a length greater then 3. Currently it is doing what I want it to do but the first time you try it in the gird it doesnt work but all the following times it does. basically if you had a grid set up like below, you could start at the top row and only the following rows will read the code and actually check the checkbox

comment,      time,    date,      checkbox

aaaa,         10:00,   14-2022,   []
aaaaaaaaaa,   10:00,   14-2022,   [x]
aaaaa,        10:00,   14-2022,   [x]
aaaa,         10:00,   14-2022,   [x]

$(document).on("keyup", "#eTmfCompletenessComment", function () {
            function dirtyField(data, fieldName) {
                if (data.dirty && data.dirtyFields[fieldName]) {
                    return "<span class='k-dirty'></span>"
                }
                else {
                    return "";
                }
            }

             var commentcheck = $(this).val()
             console.log('$(this).val() =', $(this).val())

                var grid = $('#Grid').data("kendoGrid");
                var items = grid.items();
                if (commentcheck.length > 3) {
                    //var gc = $(this).parents(".k-")
                    $(this).parents(".k-master-row").find('input[type="checkbox"]').prop("checked", true);
                   items.each(function () {
                        var dataItem = $(this).parents(".k-grid-cell").find('input[type="hidden"]');
                       set.dataItem.dirty = true;
                       dataItem.set(true);
                       dataItem.dirtyField.set(true, eTmfCompletenessActive)

                    })
                 
                }
            })
0 Answers
Related