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.

Sort string column as number

Thread ID:

Created:

Updated:

Platform:

Replies:

123832 Apr 25,2016 10:39 AM Apr 27,2016 01:28 AM JavaScript 4
loading
Tags: ejGrid
Tzelon
Asked On April 25, 2016 10:39 AM

Hey,
I have a column of severities (Critical, Major, Minor and Info). I want to sort the column like this:
Criticals
Majors
Minors
Info
As expected it sort the column by string and its not want I want. 
Is there any way to override the sort function only to this specific grid ?
or can I give to each severity a number to sort by ?


Thanks 
Tzelon  

Venkatesh Ayothi Raman [Syncfusion]
Replied On April 26, 2016 04:41 AM

Hi Tzelon, 

Thanks for contacting Syncfusion support. 

We have created a following sample for your requirement “Sort the column based on number”. We have sorted the value (Number column) field and display the Priorities (String Column) field by using template column feature in the Grid.  

Refer to the Help document, Code example and sample, 
Code example: 
$(function () { 
 
 
            var data = [{  ID: "1234", Name:"jhon",     value: 2, Priorities: "Ultra Critical" }, 
                        { ID: "1237",  Name: "Megran",  value: 1, Priorities: "RB" }, 
                        { ID: "1231",  Name: "Francis", value: 6, Priorities: "Low" }, 
                        { ID: "1233",  Name: "Paul",    value: 5, Priorities: "Normal" }, 
                        { ID: "1235",  Name: "Antony",  value: 3, Priorities: "Critical" }, 
                        { ID: "1238",  Name: "Anton",   value: 4, Priorities: "High" }, ]; 
 
 
            $("#Grid").ejGrid({ 
 
                dataSource: data, 
                allowPaging: true, 
                allowSorting: true, 
 
                columns: [ 
                          
                         { field: "ID", headerText: 'Customer ID', width: 90 }, 
 
                         { field: "Name", headerText: 'Name', width: 90 }, 
 
                    
                         { field: "value", headerText: 'Priorities',  
template: "{{:Priorties}}", textAlign: ej.TextAlign.Right, width: 70 }, 
 
                ] 
            }); 
 
        }); 






NOTE: Editing feature is not applicable for template column. 
 
Regards, 
Venkatesh Ayothiraman. 


Tzelon
Replied On April 26, 2016 07:15 AM

Thanks that's works !
quick question, where are the documentation on the templates  ?

Venkatesh Ayothi Raman [Syncfusion]
Replied On April 27, 2016 01:28 AM

Hi Tzelon, 

Thanks for the update. 

We are glad that the requirement is achieved. Please refer to the documentation link for more information, 

UG documentation for Column template: http://help.syncfusion.com/js/grid/columns#column-template 



Thanks, 
Venkatesh Ayothiraman. 


Venkatesh Ayothi Raman [Syncfusion]
Replied On April 27, 2016 01:28 AM

Hi Tzelon, 

Thanks for the update. 

We are glad that the requirement is achieved. Please refer to the documentation link for more information, 

UG documentation for Column template: http://help.syncfusion.com/js/grid/columns#column-template 



Thanks, 
Venkatesh Ayothiraman. 


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.

;