We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Column sorting



Hi,

While using  Treegrid combined with ejDatamanager pulling data from a WCF Data Service (OData Protocol) I'm having problems when sorting numeric columns. Seems like that the control is sorting data as if it was a string and not a number.

Is there any way to change this behavior?

Attachment: SyncFusionTreeGridWithODataExample_c860f840.zip

5 Replies

MK Mahalakshmi Karthikeyan Syncfusion Team September 21, 2015 04:29 PM UTC

Hi Rafael,

Sorry about the inconvenience caused.

We have facing some issue while using decimal data type values passed by the ej.DataManager to TreeGrid control. So at present we recommend you to use the float data type for the variable “LimitAmount1M”. Please refer the below code example for details.

[SampleContext.cs]

namespace SyncFusionTreeGridExample.Service

{

    [DataServiceKey("LocalFacilityId")]

    public class Facility

    {

        public String LocalFacilityId { get; set; }


        public float LimitAmount1M { get; set; }

    }

}

We have also modified your sample and you can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/120307/ze/SyncFusionTreeGridWithODataExample-691741768

Regards,

Mahalakshmi K.



RD Rafael Delanhese September 21, 2015 07:29 PM UTC


I'm afraid that I couldn't change my data type from decimal to float. 

My sample was a simplification of my real case scenario. In my real scenario the decimal field come from a EDM mapping of a money column in a sql server database, and the type money can not be mapped to a float type in C#.

Is there any prevision of when the issue will be resolved?


MK Mahalakshmi Karthikeyan Syncfusion Team September 22, 2015 01:41 PM UTC

Hi Rafael,

Sorry about the inconvenience caused.

This is due to the default behavior of the OData Serialization in which decimal/int64 literal will be converted to string. Please refer to the below link.

https://msdn.microsoft.com/en-us/library/dd541461.aspx

OData v2/v3 don’t have support to handle this (OData V4 has support) and hence to resolve this we can use the custom adaptor as follows.

$(document).ready(function() {

            var moneyHandleAdaptor = new ej.ODataAdaptor().extend({


                processResponse: function (data, ds, query, xhr, request, changes) {

                    var data = this.base.processResponse.call(this, data, ds, query, xhr, request, changes);


                    var str = JSON.stringify(data.result ? data.result : data);


                    data = JSON.parse(str, function (key, val) {


                        if (key == "LimitAmount1M")

                            val = parseFloat(val);


                        return val;

                    });


                    return data;

                }

            });


            var dataManager = ej.DataManager({ url: "/Service/DataService.svc/Facility", adaptor: new moneyHandleAdaptor() });


//…

});

We have also modified your sample according to your requirement. You can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/120307/ze/SyncFusionTreeGridWithODataExample1514505379

Regards,

Mahalakshmi K.



RD Rafael Delanhese September 23, 2015 04:43 PM UTC

Now it work's.

Thanks.


JR John Rajaram Syncfusion Team September 24, 2015 09:42 AM UTC

Hi Rafael,

Thanks for the update.

Please let us know if you require further assistance on this.

Regards,

John R


Loader.
Live Chat Icon For mobile
Up arrow icon