Issue: Traverse nested tables on client

Issue: Traverse nested tables on client

I have nested checkboxes when I select a checkbox it should select all the checkboxes below as well and same when I deselect top most checkbox. However this isn't happening. I have the following code.  This is returning length 0 v ar matches = $("#" + childId + " input[type='checkbox']"); I am using telerik to create the grid. 

HTML: IL-7797 1/22/2015 -329   1  
JQuery: 
function nestedGridRowSelected(sender, args) {
    var myId = args._id;
    var myMatches = ("#" + myId + " span");
    var childId;
    $(myMatches).each(function () { if ($(this).attr("data-customergridid")) { childId = $(this).attr("data-customergridid") } });
    var matches = $("#" + childId + " input[type='checkbox']");
    matches.prop("checked", true);
}

function nestedGridRowDeselected(sender, args) {
    var myId = args._id;
    var myMatches = ("#" + myId + " span");
    var childId;
    $(myMatches).each(function () { if ($(this).attr("data-customergridid")) { childId = $(this).attr("data-customergridid") } });
    //if (childId.is("input ")) {
    var matches = $("#" + childId + " input[type='checkbox']");
    $(matches).prop('checked', true);
    //}
}