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

Sort order numeric with xml binded datasource

8 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ingolf
Top achievements
Rank 1
Ingolf asked on 28 Dec 2011, 02:08 PM
Hi,

i have an grid with XML binded Datasource. One Column has numeric Data but the grid use alphabetic sort order. Example 1, 100, 2, 200, 3, 300 etc..
Can i use an numeric sort order (1,2,3,100,200,300) ?. How?

The Sourcecode:
$("#grid").kendoGrid({
sortable: true,
selectable: "single",
change: onChange,
            dataSource: {
serverPaging: false,
                serverSorting: false,
                
transport: {
read: {
                        url: "../GetSachbearbeiterListe",
                        dataType: "xml",
                        data: {
                            Suchbegriff: ""
                        }
                    }
                },
schema: {
                    type: "xml",
id: "f07001",
                    data: "/response/update/tabelle/satz",
total: "/response/update/anzahl/text()",
                    model: {
                        fields: {
                            f07001:  { field: "f07001/text()", type: "number" },
                            f07002: "f07002/text()",
f07110: "f07110/text()", 
f07013: { field: "f07013/text()", type: "text" }
                        }
                    }
                }
            },
scrollable: {
                virtual: false
            },
            columns: [{
field: "f07001",
title: "Sb-Nr.",
width: 20
}, {
field: "f07002",
title: "Name",
width: 100
}, {
title: "Status",
width: 30,
template: "#= gContentSachbearbeiter.formatStatusColumn(f07110) #"
}, {
field: "f07013",
width: 70,
title: "Aussendarstellung"
}
]
        });
}

8 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 29 Dec 2011, 10:46 AM
Hello Ingolf,

This behavior is because XmlDataReader of the DataSource does not convert the data to the corresponding type at the moment. This feature will be implemented for the upcoming service pack.

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
RMC
Top achievements
Rank 1
answered on 08 Feb 2012, 11:32 PM
Hi Nikolay,

I use json data, and my ID field is a number, kendoGrid handles it like string, how can I fix it?, in the schema object i have it with type 'number'.

Thanks
0
Nikolay Rusev
Telerik team
answered on 09 Feb 2012, 08:09 AM
Hello Ramon,

Please inspect the data that is being supplied to the DataSource and make sure that actual type of the ID field in the data is a number.

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andrew
Top achievements
Rank 1
answered on 24 Feb 2012, 03:38 AM
Has this indeed been rectified?

I have tried the Feb 2012 service pack, but all xml-bound data still appears as strings.  This inhibits DataSource sort and aggregate functionality.
0
RMC
Top achievements
Rank 1
answered on 24 Feb 2012, 04:36 PM
Hi Andy, Nikolay Rusev is right, your data are comming as text string, you have to convert them  to the right type, I already solved my problem, check the next link and you will find the answer:

http://www.kendoui.com/forums/framework/data-source/date-types-from-remote-json-datasource.aspx

something like:
        schema: {
                parse: function(data){
                    $.each(data, function(i,val){
                        val.clid = parseInt(val.clid);
                    });
                    return data;
                },
.....


I hope it helps you,

thanks
0
Jay
Top achievements
Rank 2
answered on 24 Feb 2012, 09:40 PM
So, how could I go about sorting numerically if my html table is already loaded in the page and so, the data type of everything is a string since it's just text enclosed in <td>12</td>??

I have set type: "number" for the appropriate columns.  I would assume that KendoUI would use this information when it transforms the html table element into a KendoGrid, is this not the case?  If not, what can I do to overcome this limitation?
0
Andrew
Top achievements
Rank 1
answered on 25 Feb 2012, 02:36 AM
RMC,

Note that I'm talking about XML data, not JSON.

In my experience, the 'parse' function is never called for XML data.

It seems the DataSource still lacks good XML support...
0
Nikolay Rusev
Telerik team
answered on 29 Feb 2012, 08:53 AM
Hello Andy,

With the current implementations of DataSource if you define the type of the field their value should be parsed depending of the type.

With upcoming beta release of Kendo UI parse functions defined for fields will be used (if specified), i.e
schema: {
 model: {
  fields: {
    id: { type: "number", parse: function(value) { return parsed value }
  }
 }
}


Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Ingolf
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
RMC
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Jay
Top achievements
Rank 2
Share this question
or