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

is it possible to sort column by a foreign key?

I have a table, which contain rows with dropdowns (foreignKeyField - value, foreignKeyValue - text). When i'm trying to sort column, it became sorted by foreignKeyField (id), not by a foreignKeyValue(text in cell). Is there a way to sort columns by a foreignKeyValue? 

1 Reply

JK Jayaprakash Kamaraj Syncfusion Team April 21, 2017 08:32 AM UTC

Hi Justpsst,

Thanks for contacting Syncfusion support.  

We have analyzed your query and we suggest you to use ForeignKeyAdaptor to sort a foreign key column based on the displayed values. ForeignKeyAdaptor supports only on local data binding. Please refer to the below code example and sample. 

  <script type="text/javascript"> 
        $(function () { 
                     var obj = {dataSource: window.employeeView, foreignKeyField: "EmployeeID", foreignKeyValue: "FirstName"}; 
                     var arr = []; 
                     arr.push(obj); 
            var data = window.gridData; 
            $("#Grid").ejGrid({ 
                dataSource: ej.DataManager({ json:data, adaptor: new ej.ForiegnKeyAdaptor(arr,"JsonAdaptor")}), 
                allowPaging: true, 
                allowSorting: true, 
                columns: [ 
                        { field: "OrderID", width: 80, textAlign: ej.TextAlign.Right,validationRules: {required:true, number: true },headerText: "Order ID"} , 
                        { field: "FirstName", width: 75, headerText: "First Name” }, 
                ] 
            }); 
        }); 
 
    </script> 


Regards, 

Jayaprakash K. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon