Treeview - How can I change the background color

1 Answer 79 Views
TreeView
Mike
Top achievements
Rank 1
Iron
Mike asked on 20 Jun 2024, 02:23 PM

I have followed all the examples but nothing is overriding the default theme.  I even tried to change it in after everything is loaded inside my done routine.

 

function createTreeView(dataURL,divName) {
    $.ajax({
        type: 'GET',
        url: dataURL,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data) {},
        error: function (request, error) {
            console.log(error);
        }
    }).done(function(data) {
         ds = new kendo.data.HierarchicalDataSource({
            data: data,
            schema: {
                model: {
                    id: "taskid",
                    children: "items",
                    hasChildren: "haschildren"
                }
            }
        });    
        $("#"+divName).kendoTreeView({
            dataSource: ds,
            dataTextField: "taskname",
            dataUrlField: "linkto"
        });
        $('.k-treeview').css('background', 'lightblue');
    })// end done
}

 

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 25 Jun 2024, 08:08 AM

Hello Mike,

I would suggest handling the dataBound event of the TreeView. In the event hanlder, you can change the color of the TreeView or its leafs as follows:

 dataBound: function(){
            $('.k-treeview').css('background', 'lightblue');
            $('.k-treeview-leaf').css('background', 'lightgreen');
}

Here is a Dojo example where this is demonstrated.- https://dojo.telerik.com/@NeliK/IYOniJET

I hope this helps.

Regards,
Neli
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
TreeView
Asked by
Mike
Top achievements
Rank 1
Iron
Answers by
Neli
Telerik team
Share this question
or