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

Sort string column as number

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  

4 Replies

VA Venkatesh Ayothi Raman Syncfusion Team April 26, 2016 08:41 AM UTC

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. 



TZ Tzelon April 26, 2016 11:15 AM UTC

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


VA Venkatesh Ayothi Raman Syncfusion Team April 27, 2016 05:28 AM UTC

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. 



VA Venkatesh Ayothi Raman Syncfusion Team April 27, 2016 05:28 AM UTC

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. 


Loader.
Live Chat Icon For mobile
Up arrow icon