EasyUI Forum

General Category => General Discussion => Topic started by: Prasad on March 07, 2016, 10:39:52 AM



Title: Pivot Grid Column Order
Post by: Prasad on March 07, 2016, 10:39:52 AM
I am using Pivot Grid to display "Jan to Dec" columns.  Unfortunately, the column order is not maintained.  I am getting random column order for each refresh/filter.  Is there a way to control the column order?


Title: Re: Pivot Grid Column Order
Post by: jarry on March 07, 2016, 08:47:43 PM
Please show an example with some sample data to demonstrate your issue.


Title: Re: Pivot Grid Column Order
Post by: Prasad on March 10, 2016, 11:56:24 PM
Sorry for the late reply.

I could not attach an image.  I tried to reproduce in jsfiddle, but didn't manage to make it work.  But I believe you could help me by looking at the code.  Thank you.

https://jsfiddle.net/zgxege1w/24/


Title: Re: Pivot Grid Column Order
Post by: jarry on March 11, 2016, 10:29:07 AM
Please refer to http://jsfiddle.net/zgxege1w/25/


Title: Re: Pivot Grid Column Order
Post by: Prasad on March 11, 2016, 03:58:57 PM
Wow, jsfiddle is working.  [I didn't expect <style> tag to be reversed]


Coming back to the original request,  Is it possible to correct the order of column in ascending?  Jul-16 followed by Dec-16.  Appreciate your help. 


Title: Re: Pivot Grid Column Order
Post by: jarry on March 11, 2016, 07:20:45 PM
You have to sort your data according to your custom logic before loading into pivotgrid.
Code:
data.sort(function(r1,r2){
...
});
$('#pg').pivotgrid({
data: data
...
});


Title: Re: Pivot Grid Column Order
Post by: Prasad on March 11, 2016, 08:33:31 PM
Thanks a lot.  Saved my day :)

http://jsfiddle.net/zgxege1w/35/