EasyUI Forum
April 26, 2024, 04:03:45 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Poll
Question: is there any problem in loading subgrid with parent datagrid which has FrozenColumns?
yes - 0 (0%)
no - 0 (0%)
Total Voters: 0

Pages: [1]
  Print  
Author Topic: Subgrid is loading within frozen columns of ParentGrid  (Read 28062 times)
kush
Newbie
*
Posts: 29


View Profile Email
« on: October 21, 2014, 03:30:24 AM »

Hi,
I have A requirement of loading subgrid with Parent Frozen columns.I have implemented on the same ...But the problem is onExpandRow the subgrid is loading within parent frozen columns HTML div structure.There are Panels created in DoM.like datagrid-view1
 and datagrid-view2.The subgrid should created inside datagrid-view1.But it is creating in datagrid-view2.
Please help me in resolving the issue soon.
Below is my code



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name="keywords" content="spark,RPT,spark datagrid">
   <meta name="description" content="SPARK, RPT DATA GRID">
   <title>SPARK DATA GRID</title>
   <link rel="stylesheet" type="text/css" href="css/easyui.css">
   <link rel="stylesheet" type="text/css" href="css/icon.css">
   <link rel="stylesheet" type="text/css" href="css/demo.css">
   <link rel="stylesheet" type="text/css" href="css/datagrid.css">
   <link rel="stylesheet" type="text/css" href="css/dg_custom_styles.css">
   <script type="text/javascript" src="js/jquery-1.6.min.js"></script>
   <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
   <script type="text/javascript" src="js/jquery.edatagrid.js"></script>
   <script type="text/javascript" src="js/datagrid-detailview.js"></script>
   <script type="text/javascript">
   //Global Variables Declaration
   var gridRowsData = [];
   var gridColumnsNames = [];
   var gridFrozenColumnes = [];
   var subGridRowsData = [];
   var subGridColumnNames = [];
   var subGridFrozenColumnes = [];
   var items = [];
      $.getJSON( "php/projects.json", function( data ) {

$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
});
console.log('json'+ items);
   //Getting the data from projects.json and pushing to frozen , columns , rows arrays
   $.getJSON('php/projects.json', function(data) {
   gridColumnsNames.push(data.columns);
   gridRowsData = data.rows;
   //gridRowsData.push(data.rows);
   gridFrozenColumnes.push(data.frozenColumns);
   //loads datagrid content dynamically using edatagrid component
   $('#dg').datagrid({
    data: gridRowsData,
   frozenColumns: gridFrozenColumnes,
   columns: gridColumnsNames,
   display:'block',
   width:'100%',
   height:'auto',
   view: detailview,
   detailFormatter:function(index,row){
      return '<div style="padding:2px"><table id="ddv_' + index + '"></table></div>';
   },
   onExpandRow: function(index,row){
   subGridRowsData = []; subGridColumnNames = []; subGridFrozenColumnes = [];
   $.getJSON('php/subgrid/pr_'+row.project_id+'.json', function(data1) {
   subGridRowsData = data1.rows;
   subGridColumnNames.push(data1.columns);
   console.log(subGridColumnNames);
   subGridFrozenColumnes.push(data1.frozenColumns);
    $('#ddv_'+index).datagrid({
      data:subGridRowsData,
      fitColumns:true,
      singleSelect:true,
      rownumbers:true,
      columns: subGridColumnNames,
      frozenColumns: subGridFrozenColumnes,
      height:'auto',
      onResize:function(){
         $('#dg').datagrid('fixDetailRowHeight',index);
},
      onLoadSuccess:function(){
         setTimeout(function(){
            $('#dg').datagrid('fixDetailRowHeight',index);
         },0);
       }
    });
    $('#dg').datagrid('fixDetailRowHeight',index);
   
   });
   
   },
    });
   });
   </script>
</head>
<body>
   <table id="dg" title="Project Datagrid" style="width:100%;height:250px"
         pagination="true" idField="id"
         rownumbers="false" fitColumns="true" singleSelect="true">

   </table>
</body>
</html>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 22, 2014, 12:40:20 AM »

In the 'onExpandRow' event handler, you must get the row detail container in the frozen side and then create the sub grid in it. Please refer to the following code.
Code:
onExpandRow:function(index,row){
var opts = $(this).datagrid('options');
var tr = opts.finder.getTr(this, index, 'body', 1);
var c = tr.next().find('>td>div.datagrid-row-detail').empty();
var dg = $('<table></table>').appendTo(c);
dg.datagrid({
height:50,
columns:[[
{field:'f1',title:'Title1',width:50},
{field:'f2',title:'Title2',width:50}
]]
});
$(this).datagrid('fixDetailRowHeight',index);
}
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #2 on: October 22, 2014, 04:55:39 AM »

Hi Thanks a lot ..Its working now .. Smiley Exploring with Easyui
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #3 on: October 23, 2014, 09:28:27 PM »

Hi ,
      After following the below code its not showing scrollbar to the columns next to Frozen columns.I have FozenColumns and columns.Frozen Columns are displayed to left.And columns next following by Frozen .its not showing the scrollbar to columns.However main grid is displayed with scrollbar.
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #4 on: October 23, 2014, 09:32:42 PM »

please find the screenshot on the same.Here till type columns its frozen.From jan24 columns ,not showing scrollbar
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: October 24, 2014, 12:56:53 AM »

Please try to add the code below to your page.
Code:
	<style type="text/css">
.datagrid-row-detail .datagrid-view2 .datagrid-body{
overflow: auto;
}
</style>
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #6 on: October 27, 2014, 05:00:36 AM »

Hi I am facing one more ui issue.
I have Parent Grid with frozen columns and subgrid with frozen columns.Frozen  columns should occupy 50% and Columns to 50% As i have set in css.However in subgrid it is showing the right columns.Something is overlapping.I played with Z-index .But still dint work,Please help.Please look in the attachment

and css code is

.panel.datagrid.easyui-fluid {
  margin:0 auto;
  width: 1105px !important;
}
.panel-header {
  padding: 0.5% !important;
  width: 98% !important;
}
.datagrid-wrap.panel-body {
  width: 99% !important;
}
.datagrid-view {
  width: 100% !important;
}
.datagrid-view1 {
  width: 50% !important;
}
.datagrid-view2 {
  width: 50% !important;
}
.datagrid-header {
  width: 100% !important;
}
.datagrid-body {
  width: 100% !important;
}
.datagrid-footer {
  width: 100% !important;
}
.datagrid-pager.pagination {
  width: 100% !important;
}
.datagrid-header-inner {
  float: left;
  width: 100% !important;
}
.header_color_line{
background: url("images/Navigation_Logo.png") repeat-x scroll 0 0 / 100% 100% rgba(0, 0, 0, 0);
clear: both;
display: block;
height: 32px;
margin: 0 16px !important;
width: 1096px !important;
}
.footer_color_line{
background: url("images/Navigation_Logo.png") repeat-x scroll 0 0 / 100% 100% rgba(0, 0, 0, 0);
clear: both;
display: block;
height: 32px;
margin: 0 16px !important;
width: 1096px !important;
}
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #7 on: October 27, 2014, 08:13:36 AM »

Please have a look at the attachment.on the expand row of datagrid subgrid is  not occupied fully.only the frozen (ie the left side columns) columns are visible.rest of the columns are in background.please help me in fixing this.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #8 on: October 27, 2014, 08:46:04 AM »

Please try to set the 'fitColumns' property to true for your sub grid to let it full fill its parent container.
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #9 on: October 27, 2014, 11:33:22 AM »

I had already mentioned in datagrid properties fitColumns.Please look into below html code.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name="keywords" content="spark,RPT,spark datagrid">
   <meta name="description" content="SPARK, RPT DATA GRID">
   <title>SPARK DATA GRID</title>
   <link rel="stylesheet" type="text/css" href="css/easyui.css">
   <link rel="stylesheet" type="text/css" href="css/icon.css">
   <link rel="stylesheet" type="text/css" href="css/demo.css">
   <link rel="stylesheet" type="text/css" href="css/datagrid.css">
   <script type="text/javascript" src="js/jquery-1.6.min.js"></script>
   <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
   <script type="text/javascript" src="js/jquery.edatagrid.js"></script>
   <script type="text/javascript" src="js/datagrid-detailview.js"></script>
   <link rel="stylesheet" type="text/css" href="css/dg_custom_styles.css">
   <script type="text/javascript">
   //Global Variables Declaration
   var gridRowsData = [];
   var gridColumnsNames = [];
   var gridFrozenColumnes = [];
   var subGridRowsData = [];
   var subGridColumnNames = [];
   var subGridFrozenColumnes = [];

   //Getting the data from projects.json and pushing to frozen , columns , rows arrays
   $.getJSON('php/projects.json', function(data) {
   gridColumnsNames.push(data.columns);
   gridRowsData = data.rows;
   //gridRowsData.push(data.rows);
   gridFrozenColumnes.push(data.frozenColumns);
   //loads datagrid content dynamically using edatagrid component
   $('#dg').datagrid({
    data: gridRowsData,
   frozenColumns: gridFrozenColumnes,
   columns: gridColumnsNames,
   display:'block',
   width:'100%',
   height:'auto',
   view: detailview,
   detailFormatter:function(index,row){
      //return '<div style="padding:2px"><table id="ddv_' + index + '"></table></div>';
   },
   onExpandRow: function(index,row){
   var opts = $(this).datagrid('options');
   var tr = opts.finder.getTr(this, index, 'body', 1);
   var c = tr.next().find('>td>div.datagrid-row-detail').empty();
   var dg = $('<table></table>').appendTo(c);
   subGridRowsData = []; subGridColumnNames = []; subGridFrozenColumnes = [];
   $.getJSON('php/subgrid/pr_'+row.project_id+'.json', function(data1) {
   subGridRowsData = data1.rows;
   subGridColumnNames.push(data1.columns);
   console.log(subGridColumnNames);
   subGridFrozenColumnes.push(data1.frozenColumns);
    dg.datagrid({
      data:subGridRowsData,
      fitColumns:true,
      singleSelect:true,
      rownumbers:true,
      columns: subGridColumnNames,
      frozenColumns: subGridFrozenColumnes,
      height:'auto',
      onResize:function(){
         $('#dg').datagrid('fixDetailRowHeight',index);
},
      onLoadSuccess:function(){
         setTimeout(function(){
            $('#dg').datagrid('fixDetailRowHeight',index);
         },0);
       }
    });
    $('#dg').datagrid('fixDetailRowHeight',index);
   
   });
   
   },
    });
   });
   </script>
</head>
<body>
<div class="header_color_line"></div>
   <table id="dg" title="Project Datagrid" style="width:100%;height:250px"
         pagination="true" idField="id"
         rownumbers="false" fitColumns="true" singleSelect="true">

   </table>
    <div class="footer_color_line"></div>
</body>
</html>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #10 on: October 27, 2014, 06:59:05 PM »

The width of '.datagrid-view1' depends on the total width of frozen columns. If you want to allocate 50% space of grid for the frozen columns, please set the width with percentage value for the frozen columns.
Code:
$('#tt').datagrid({
frozenColumns:[[
{field:'itemid',title:'Item ID',width:'25%'},
{field:'productid',title:'Product ID',width:'25%',sortable:true}
]],
columns:...
})
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #11 on: October 27, 2014, 11:37:10 PM »

Thanks for your valuable response

I have given the width of frozenColums fields in % values.
Along with the css
.datagrid-view2 {
  width: 50% !important;
}
still i see the subgrid  half filled in the ui

actually i need this subgrid independent to fill in the ui area on the dataview2 also as currently it is not displaying.

 

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #12 on: October 27, 2014, 11:49:57 PM »

One sub grid can only be placed in either datagrid-view1 or datagrid-view2. Please try the code below to create two sub grid in the detail view.
Code:
onExpandRow:function(index,row){
var target = this;
var opts = $(target).datagrid('options');
createGrid(true);
createGrid();
$(target).datagrid('fixDetailRowHeight',index);

function createGrid(frozen){
var tr = opts.finder.getTr(target, index, 'body', frozen?1:2);
var c = tr.next().find('>td>div.datagrid-row-detail').empty();
var dg = $('<table></table>').appendTo(c);
dg.datagrid({
height:100,
fitColumns:true,
frozenColumns:[[
{field:'f0',title:'Title0',width:50}
]],
columns:[[
{field:'f1',title:'Title1',width:50},
{field:'f2',title:'Title2',width:50}
]]
});
}
}
Logged
kush
Newbie
*
Posts: 29


View Profile Email
« Reply #13 on: October 28, 2014, 12:43:46 AM »

Thanks lot for quick response.my requirement is not to create two sub grids in the detail view.
I have only one subgrid on click of expand row.But the problem is The subgrid is displayed only 50% of datagrid.The reason is to the parent grid i had given the below css because my requirement was to show 50% to frozen and 50% to columns.
.datagrid-view1 {
  width: 50% !important;
}
.datagrid-view2 {
  width: 50% !important;
}

.If I remove  this css
 .datagrid-view1 {
  width: 50% !important;
} the subgrid is fitting to 100% of width.And few columns were overlapped because I am having 19 columns in frozen columns
Please look the same in attached image.




 
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #14 on: October 28, 2014, 01:17:15 AM »

You can not put a sub grid through the datagrid-view1 and datagrid-view2. This is why the sub grid displays at 50% width of datagrid.
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!