This is a migrated thread and some comments may be shown as answers.

Setting a checkbox on a TreeView to a default value

0 Answers 233 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lisa
Top achievements
Rank 1
Lisa asked on 11 Sep 2013, 04:15 PM
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");

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Lisa
Top achievements
Rank 1
Share this question
or