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.
Unfortunately, activation email could not send to your email. Please try again.

Column sorting

Thread ID:

Created:

Updated:

Platform:

Replies:

120307 Sep 18,2015 03:35 PM Sep 24,2015 05:42 AM JavaScript 5
loading
Tags: ejTreeGrid
Rafael Delanhese
Asked On September 18, 2015 03:35 PM



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

Mahalakshmi Karthikeyan [Syncfusion]
Replied On September 21, 2015 12:29 PM

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.


Rafael Delanhese
Replied On September 21, 2015 03:29 PM


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?

Mahalakshmi Karthikeyan [Syncfusion]
Replied On September 22, 2015 09:41 AM

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.


Rafael Delanhese
Replied On September 23, 2015 12:43 PM

Now it work's.

Thanks.

John Rajaram [Syncfusion]
Replied On September 24, 2015 05:42 AM

Hi Rafael,

Thanks for the update.

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

Regards,

John R


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;