EasyUI Forum
April 24, 2024, 09:20:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Dynamic columns  (Read 12692 times)
Pierre
Sr. Member
****
Posts: 439


View Profile Email
« on: May 31, 2013, 08:20:15 AM »

Hi all
I need to create datagrid columns "on the fly".
Here is what I have:

Code:
$.get("/json/members_tabs.json",
{
  }).done(function(data)
{
  $('#member_invoice').datagrid({
  url:'/json/member_invoice.json', 
  columns: [[{field:"_date",title:"Date"},{field:"document",title:"Name"},{field:"shipping",title:"Price",align:"right"}]] 
  //columns: data
 });
});

my "data" contain same value as above, but it does not work.
Why not?
I mean, if I use this:
  columns: data
and inside "data" is this:
[[{field:"_date",title:"Date"},{field:"document",title:"Name"},{field:"shipping",title:"Price",align:"right"}]]
it will not work, and if I use this:
  columns: [[{field:"_date",title:"Date"},{field:"document",title:"Name"},{field:"shipping",title:"Price",align:"right"}]]
it works.

What I need to do so I can create columns on the fly?
I found this answer:
http://www.jeasyui.com/forum/index.php?topic=286.msg681#msg681
but it is same as above - If I use my data instead od "hardcoded" values - it does not work.
Thanks for help.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 01, 2013, 08:49:51 AM »

Please check the data returned from '/json/members_tabs.json' to see if it is correct. Here is the example that create columns dynamically.
http://jsfiddle.net/H5rkg/
Logged
Pierre
Sr. Member
****
Posts: 439


View Profile Email
« Reply #2 on: June 01, 2013, 01:11:34 PM »

Thank you for your solution, thanks a lot.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!