EasyUI Forum
May 17, 2024, 06:08:34 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: hi, how can I show a tree instead the datagrid in a subgrid?  (Read 9175 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: January 09, 2014, 12:28:58 PM »

I saw this demo:

http://www.jeasyui.com/tutorial/datagrid/datagrid22.php

And what I need is show a tree instead the datagrid

that is possible??
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: January 09, 2014, 05:39:46 PM »

It is easy to display any components in the row detail container. The code below shows how to achieve this functionality.

Code:
$('#dg').datagrid({
view: detailview,
detailFormatter:function(index,row){
return '<div style="position:relative;overflow:auto;padding:2px;height:100px"><ul class="ddv"></ul></div>';
},
onExpandRow: function(index,row){
var ul = $(this).datagrid('getRowDetail',index).find('ul.ddv');
ul.tree({
//...
});
$('#dg').datagrid('fixDetailRowHeight',index);
}
});
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #2 on: January 09, 2014, 06:44:59 PM »

awesome stworthy

 Shocked

Im very thankful
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #3 on: January 13, 2014, 08:20:43 AM »

Hi

Continuing with the example,
place a tree in the subgrid
the tree has a checkbox to true

my problem is when :

- Open a row (+) and I get the list of tree that row , then I check some options
- Close that row (-)
- I open the back row ( +) and the options I had checked, no longer remain active

eg

1.-
--------------------------------------------------------------
| - | row1-colum1 | row1-colum 2                              |
--------------------------------------------------------------
|     | + | subrow1-column1 | subrow1-column1          |    --> if open this subrow
--------------------------------------------------------------
|     | + | subrow2-column1 | subrow2-column1          |
--------------------------------------------------------------
| + | row2-colum1 | row2-colum 2                             |
--------------------------------------------------------------
| + | row3-colum1 | row3-colum 2                             |
--------------------------------------------------------------

2.-
--------------------------------------------------------------
| - | row1-colum1 | row1-colum 2                              |
--------------------------------------------------------------
|     | - | subrow1-column1 | subrow1-column1           |
--------------------------------------------------------------
|             * [] Fruits                                                  |  --> get the tree
|             --- * [] apple                                             |
|             --- * [] orange                                           |      
--------------------------------------------------------------
|     | + | subrow2-column1 | subrow2-column1          |
--------------------------------------------------------------
| + | row2-colum1 | row2-colum 2                             |
--------------------------------------------------------------
| + | row3-colum1 | row3-colum 2                             |
--------------------------------------------------------------

3.-
--------------------------------------------------------------
| - | row1-colum1 | row1-colum 2                              |
--------------------------------------------------------------
|     | - | subrow1-column1 | subrow1-column1           |
--------------------------------------------------------------
|             * [ / ] Fruits                                               |  --> check some items
|             --- * [ / ] apple                                          |
|             --- * [] orange                                           |      
--------------------------------------------------------------
|     | + | subrow2-column1 | subrow2-column1          |
--------------------------------------------------------------
| + | row2-colum1 | row2-colum 2                             |
--------------------------------------------------------------
| + | row3-colum1 | row3-colum 2                             |
--------------------------------------------------------------

4.-
--------------------------------------------------------------
| - | row1-colum1 | row1-colum 2                              |
--------------------------------------------------------------
|     | + | subrow1-column1 | subrow1-column1          | --> close the subrow1
--------------------------------------------------------------
|     | + | subrow2-column1 | subrow2-column1          |
--------------------------------------------------------------
| + | row2-colum1 | row2-colum 2                             |
--------------------------------------------------------------
| + | row3-colum1 | row3-colum 2                             |
--------------------------------------------------------------

5.-
--------------------------------------------------------------
| - | row1-colum1 | row1-colum 2                              |
--------------------------------------------------------------
|     | - | subrow1-column1 | subrow1-column1           |
--------------------------------------------------------------
|             * [] Fruits                                                  |  --> open again subrow1 and the options I had selected, no longer remain active
|             --- * [] apple                                             |
|             --- * [] orange                                           |      
--------------------------------------------------------------
|     | + | subrow2-column1 | subrow2-column1          |
--------------------------------------------------------------
| + | row2-colum1 | row2-colum 2                             |
--------------------------------------------------------------
| + | row3-colum1 | row3-colum 2                             |
--------------------------------------------------------------

What I can do to make the boxes I check stay active?

here is my code

Code:
$('#dg').datagrid({
view: detailview,
detailFormatter:function(index,row){
return '<div style=\'padding:2px\'><table id=\'ddv-'+index+'\'></table></div>';
},
onExpandRow: function(index,row){
$('#ddv-'+index).datagrid({
title:'',
url:'get_data.php?id_s='+row.id_s+'&id_c='+row.id_c+'&id_p='+row.id_p,
fitColumns:false,
singleSelect:true,
rownumbers:true,
nowrap:false,
width:790,
height:'auto',
pagination:true,
pageSize:5,
pageList:[5,10,15,20],
columns:[[
{field:'clave',title:'Clave',width:100,sortable:true},
{field:'desc',title:'Descripcion',width:630,sortable:true}
]],
onResize:function(){
$('#dg').datagrid('fixDetailRowHeight',index);
},
onLoadSuccess:function(data){
setTimeout(function(){
$('#dg').datagrid('fixDetailRowHeight',index);
},0);
},
view: detailview,
detailFormatter:function(indext,rowt){
return '<div style="position:relative;overflow:auto;padding:2px;height:130px"><ul id=\'tdv-'+rowt.id_a+indext+'\'></ul></div>';
},
onExpandRow: function(indext,rowt){
$('#tdv-'+rowt.id_a+indext).tree({
url: 'get_data2.php?id_c='+rowt.id_c,
lines: true,
checkbox: true,
cascadeCheck: false,
loadFilter:function(rows){
return convert(rows);
}
});
}
});
$('#dg').datagrid('fixDetailRowHeight',index);
}
});
« Last Edit: January 13, 2014, 08:32:06 AM by catpaw » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: January 14, 2014, 01:19:59 AM »

To solve your issue, please prevent from re-creating tree component again when expand a row. Try the code below:
Code:
onExpandRow: function(indext,rowt){
var t = $('#tdv-'+rowt.id_a+indext);
if (!t.data('tree')){
t.tree({
url: 'get_data2.php?id_c='+rowt.id_c,
lines: true,
checkbox: true,
cascadeCheck: false,
loadFilter:function(rows){
return convert(rows);
}
});
}
}
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #5 on: January 14, 2014, 07:22:07 AM »

perfect!!!

thank you very much, all your work is amazing

 Grin
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!