how to conditionally click a checkbox based on another cells length when the user tabs out or clicks out of a cell

0 Answers 73 Views
Checkbox Editor Grid
adam
Top achievements
Rank 1
adam asked on 14 Sep 2022, 03:39 PM

https://stackoverflow.com/questions/73719432/how-to-conditionally-click-a-checkbox-in-telerik-grid-based-on-another-column-in


function onSave(e) 
    {

        //console.log(e.container.find("input[name=eTmfCompletenessComment]").val());

        //if (e.values.eTmfCompletenessComment.length > 3) 
        //{
        //    e.values.eTmfCompletenessActive == true;
        //}
        
        //if (e.container.find("input[name=eTmfCompletenessComment]").val().length > 3) 
        //{
        //    console.log(e.container.uid);
        //    //checkbox cell is in editmode
        //    e.container.find("input[name=eTmfCompletenessActive]").checked == true;
        //    //e.container.item.find("input[name=eTmfCompletenessActive]").checked == true;
            
        //}
       
        $(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)

                    //})
                 
                }
            })

        console.log("onSave");
    }

adam
Top achievements
Rank 1
commented on 14 Sep 2022, 03:40 PM

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
adam
Top achievements
Rank 1
commented on 14 Sep 2022, 03:40 PM


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]

Anton Mironov
Telerik team
commented on 19 Sep 2022, 02:58 PM

Hi Adam,

Thank you for the details provided.

The pointed custom checkbox should get into edit mode first. Probably this is causing the pointed issue.

Is it possible to send me a runnable sample of the application, or a dojo example? Once I have the issue represented locally will try my best to fix it.

Looking forward to hearing back from you.

Kind Regards,
Anton Mironov

No answers yet. Maybe you can help?

Tags
Checkbox Editor Grid
Asked by
adam
Top achievements
Rank 1
Share this question
or