EasyUI Forum
May 09, 2024, 08:40:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: create columns in SubGrid from a JSONObject.  (Read 4707 times)
Bin
Newbie
*
Posts: 2


View Profile Email
« on: November 05, 2015, 05:03:29 AM »

hello all,

I am new to easyui and encounter  a problem with DataGrid when trying to create columns from a JSONObject in SubGrid.

Here's my Java script:

onExpandRow: function(index,row){
                var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
                ddv.datagrid({
                    url:'FFDDR!rowExpend?s_PID='+row.ProtocolId,
                    loadMsg:'Loading ...',
                    fitColumns:true,
                    singleSelect:true,
                    rownumbers:true,
                    onResize:function(){
                        $('#dg').datagrid('fixDetailRowHeight',index);
                        $('#dg').datagrid('fixRowHeight',index);
                    },
                    onLoadSuccess:function(data, param){
                        ddv.datagrid({
                            columns:[data.columns]                       //Columns are created, but NOT shown in SubGrid
                        });
                        ddv.datagrid("loadData", data.rows);        //Data can be loaded to table and will show in SubGrid
                        setTimeout(function(){                                  
                            $('#dg').datagrid('fixDetailRowHeight',index);
                            $('#dg').datagrid('fixRowHeight',index);
                        },0);
                    }
                });

[data.columns] looks like this:
"columns":[{"field":"sequence_nr","title":"sequence_nr","width":100},{"field":"kind_of_test","title":"kind_of_test","width":100}]
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 05, 2015, 07:25:17 AM »

Please try this:
Code:
onExpandRow: function(index,row){
var ddv = $(this).datagrid('getRowDetail',index).find('.ddv');
$.ajax({
url: 'FFDDR!rowExpend?s_PID='+row.ProtocolId,
dataType: 'json',
// ...
success: function(data){
ddv.datagrid({
columns: [data.columns],
data: data.rows,
// ...
});
$('#dg').datagrid('fixDetailRowHeight',index);
}
})
}
Logged
Bin
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: November 05, 2015, 06:25:39 PM »

Hello administrator,

Many thanks for your kind help.
It works perfectly.   Smiley Smiley Smiley


Thanks & Regards,
Bin
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!