Hello stworty,
I'm sorry for not being clear. I've been able to create a datagrid with dynamic columns already. The javascript code snippet for the same can be found below:
data = {"COL_DATA":[
{"field":"col_0","title":"Column 1","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_1","title":"Column 2","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_2","title":"Column 3","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_3","title":"Column 4","sortable":"true","width":"25.0%","align":"left","halign":"center"}
]}
data = JSON.parse(data);
var columns = data.COL_DATA;
col_data = [columns];
$("#dg").datagrid({
columns: col_data,
url: "ajax_url", //ajax url to load the data
pagination: true,
pagePosition: 'both',
multiSort:true,
remoteSort:false,
striped:true
});
This creates my datagrid as needed. I however want to create a grid having grouped columns as shown in the followng url:
http://www.jeasyui.com/tutorial/datagrid/datagrid9.phpI'm confused on how to add the additional sub columns/grouped columns in the JSON object:
data = {"COL_DATA":[
{"field":"col_0","title":"Column 1","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_1","title":"Column 2","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_2","title":"Column 3","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_3","title":"Column 4","sortable":"true","width":"25.0%","align":"left","halign":"center"},
{"field":"col_3_1","title":"Column 4.1","sortable":"true","width":"12.5%","align":"left","halign":"center"}, //will add new column instead of being a sub column
{"field":"col_3_2","title":"Column 4.2","sortable":"true","width":"12.5%","align":"left","halign":"center"} //will add new column instead of being a sub column
]}
As shown in the above code the json data will create two new columns in the datagrid. However I want the "col_3_1" and "col_3_2" to be contained within the "col_3" column.
How can I do the same using JSON???
Regards,
Darrel.