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

Bind grid control to linked list

Hello,
I'm new in SyncFusion, but read some documentation, and did not found how to connect a grid to a set of records, when each record is an object linked to next / previous objects instances.
I would like to not create an array or a collection to submit records to a grid, but only declare next / previous properties.
Or I can write my "own" iterator/adaptor, but did not found some guide to do this (extends ej.Adaptor?).
I'm not searching a full solution (but would appreciate it :-), but just some advice or path to documentation.
Thanks!

4 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team January 13, 2017 07:18 AM UTC

Hi David, 

Thanks for contacting Syncfusion support. 

      Queries 
                                               Response 

how to connect a grid to a set of records” 


To bind the records in grid, we need to provide Json array as a Grid datasource.  
 
Find the code example and sample:  
 
 
  $("#Grid").ejGrid({ 
              dataSource: [{ OrderID : 10248, CustomerID : "ASWFG" }, { OrderID : 10249, CustomerID : "ADSFG" }], 
                allowPaging: true,           
                columns: [ 
                         { field: "OrderID", headerText: "Order ID", width: 75 , textAlign: ej.TextAlign.Right }, 
                         { field: "CustomerID", headerText: "Customer ID", width: 80 }, 
                         
                ] 
            }); 
 
  
Query :“when each record is an object linked to next / previous objects instances.”  

We cannot understand the above requirement. So, Can you please elaborate your requirement? It will be helpful to update the proper solution.  


Or I can write my "own" iterator/adaptor, but did not found some guide to do this (extends ej.Adaptor?).” 


Yes, you can create own adaptor in Grid. For more information, please refer the below document. 




Regards, 
Prasanna Kumar N.S.V 



DL David Lantier January 13, 2017 09:18 AM UTC

Query :“when each record is an object linked to next / previous objects instances.”  
Here an example, 3 objects that are connected in bi directional linked list via 2 references (next, prev).
This should be very fast and flexible (for example, next, prev could rely of real time sorted treap), allowing me (and component) to handle real time change in data source.
Ideal for virtual components.

// 3 instanced objects
var o1 = { name: "n1" };
var o2 = { name: "n2" };
var o3 = { name: "n3" };

// first, last of linked list
var first = o2;
var last = o3;

// objects are bi directional linked: o2 <-> o1 <-> o3
o1.next = o3; o3.prev = o1;
o2.next = o1; o1.prev = o2; first = o2;
o3.next = null; o1.prev = null;

/*
// want to be able to set a list that display, something like this:
list.next = "next";
list previous = "prev";
list.first = o2;

Ie. without have to construct an array of objects
Ideally, this could be fine for virtual grid, list, tree, ...

// shoud produce
n2
n1
n3
*/


DL David Lantier January 13, 2017 09:22 AM UTC

Correction

// objects are bi directional linked: o2 <-> o1 <-> o3
o1.next = o3; o3.prev = o1;
o2.next = o1; o1.prev = o2;
o3.next = null; o2.prev = null;


PK Prasanna Kumar Viswanathan Syncfusion Team January 16, 2017 12:48 PM UTC

Hi David, 

We analyzed your query and we don’t have inbuilt support to bind the bidirectional linked list data to the Grid. So, we suggest you to write an algorithm to convert list data to Json array. i.e if we list data like o2<>o1<>o3 then click the button to convert json, first push the item o2 into an array and move to next item based on the address in the item o2 and then push the items repeatedly until the list contains null address. Then bind the converted Json data to the  Grid control using dataSource method. 
  
Refer to the Help document for the dataSource method. 

  
Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon