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

How to perform case-insensitive sort in Tree view?

3 Answers 227 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Barani
Top achievements
Rank 1
Barani asked on 10 Jan 2013, 09:48 PM
I am using the below code to sort the value of the tree, it seems like the sorting happens based on case. I am trying to figure out a way to perform case insensitive sorting, can you please help me with that?

if(sortValue == 'Ascending')
{
$("#groupTree").data("kendoTreeView").dataSource.sort({ field: "text", dir: "asc" });
} else if(sortValue == 'Descending')
{
$("#groupTree").data("kendoTreeView").dataSource.sort({ field: "text", dir: "desc" });
}
}

Thanks,
Barani

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 11 Jan 2013, 04:42 PM
Hello Barani,

Case-insensitive sorting is currently not supported. Here is the corresponding uservoice feature suggestion. As a work-around, you can add a field to the model when the response is parsed -- see the following jsBin.

Kind regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Barani
Top achievements
Rank 1
answered on 16 Jan 2013, 09:44 PM
Hi,

I tried your suggestion, but for some reason the tree view is not getting displayed properly (its just displaying the parent) if I use schema property.

 var localDataSource = new kendo.data.HierarchicalDataSource({
        data:uniqueFinalPath,
        schema: {
            parse: function(data) {
                for (var i = 0; i < data.length; i++) {
                    if(data[i]){
                        process( data[i]);
                    }
                }
                return data;
            }
        },
        model: {
          id: "id"
        }

    });

Do I need to make any changes for tree to list its childrens?

Please find below the final object,

{
    "id":"1237",
    "text":"BUSINESS",
    "encoded":false,
    "items":[{
        "id":"234",
        "text":"BUSINESS1",
        "encoded":false,
        "items":[{
            "id":"456",
            "text":"SOUTHEAST",
            "encoded":false,
            "items":[{
                "id":"567",
                "text":"SOUTHEAST BB",
                "encoded":false,
                "lowerText":"southeast bb"
            }],
            "lowerText":"southeast"
        }],
        "lowerText":"business"
    }],
    "lowerText":"business1"
}
0
Alex Gyoshev
Telerik team
answered on 17 Jan 2013, 08:12 AM
Hello Barani,

You need to specify children: "items" in the model, since declaring a model will replace the defaults. Also, the model declaration needs to be within the schema. See the updated jsBin for a working example (although this sample data did not show the sorting, so I took the liberty of adding a dummy entry).

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Barani
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Barani
Top achievements
Rank 1
Share this question
or