Setting a checkbox on a TreeView to a default value

1 posts, 0 answers
  1. Lisa
    Lisa avatar
    35 posts
    Member since:
    May 2011

    Posted 11 Sep 2013 Link to this post

    Hi - I have a TreeView defined as one of a series of filters for my page.  I want to be able to send in default values so that when the user first brings up the page, they have values for the chart.  What I can't seem to figure out is how to set the checkbox for the value I am sending in.  I can do it on my TreeViews that are radio buttons.  I can also set all the checkboxes to checked, but can't find the right syntax to set just one. 

    I have tried a variety of syntax.  gradeLevelParm is the value I am passing:
    $("#gradeLevelFilterTree input[value='" + gradeLevelParm + "']").click();
     $("#gradeLevelFilterTree input:checkbox"[value = gradeLevelParm]).click();
     $("#gradeLevelFilterTree input:checkbox[value='" + gradeLevelParm + "']").click();

    This selects all the checkboxes, when I want one specific set.
    $("#gradeLevelFilterTree input:checkbox").click();

    Thanks for any help!

    Here is the code that I have creating the TreeView.
    ktvGradeLevelFilter = $("#gradeLevelFilterTree").kendoTreeView({
        dataTextField: ["text", "GradeLevelID"],
        dataSource: {
            transport: {
                read: function (options) {
                    $.getJSON(Helpers.toServicesUrl("/GetfltEWSGradeLevel"),
                        {
                            username: Context.UserName,
                            districtId: Context.DistrictId,
                            //                                schoolType: "H"
                            schoolType: schoolTypeParm //ktvSchoolFilter.getSelectedSchoolType()
                        },
                        function (data) {
                            gradeLevelData = data.GetfltEWSGradeLevelResult.RootResults;
                            gradeLevelData = [{
                                text: "Grade Level(Counts by Risk Factor)",
                                items: gradeLevelData,
                                expanded: false
                            }];
                            options.success([]);
                            ktvGradeLevelFilter.dataSource.data(gradeLevelData);
     
                             
                        }).fail(function (jqXHR) {
                            options.error(jqXHR);
                        });
                }
            },
            schema: {
                model: {
                    children: "items"
                }
            }
        },
        checkboxes: {
            checkChildren: true
        }
    }).data("kendoTreeView");
Back to Top