EasyUI Forum
April 19, 2024, 05:26:14 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: TreeGrid Merge / Span Columns  (Read 6107 times)
pjobbins
Newbie
*
Posts: 4


View Profile
« on: April 30, 2018, 09:35:05 PM »

Is it possible to to have a cell span columns in the TreeGrid?  e.g. the long folder name in the screenshot attached.

NB  I tried adapting the process described for DataGrid cell merging cells here: https://www.jeasyui.com/tutorial/datagrid/datagrid13.php

e.g. ... onLoadSuccess: function (row, data) {$('#tt').treegrid('mergeCells', { index: 2, field: 'name', colspan: 3 }); }

But no joy.
« Last Edit: April 30, 2018, 09:45:56 PM by pjobbins » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: May 01, 2018, 06:40:14 PM »

The better way to display a long folder title is to attach a css class on the folder rows, define some css styles to let the title override the cells.
Code:
<style type="text/css">
.trow .datagrid-cell{
overflow: visible;
}
.trow td:not(:last-child){
border-right-color: transparent;
}
</style>
$('#tg').treegrid({
columns: [[
{field:'name',title:'Name',width:200},
{field:'size',title:'Size',width:100},
{field:'date',title:'Date',width:150}
]],
data: data,
idField: 'id',
treeField: 'name',
rowStyler: function(row){
if (row.children && row.children.length){
return {class:'trow'}
}
}
})

For more information please look at this live example http://code.reloado.com/upuwoq3/edit#preview
Logged
pjobbins
Newbie
*
Posts: 4


View Profile
« Reply #2 on: May 02, 2018, 08:06:56 PM »

Thanks jarry.  That works well until the text is longer as it doesn't wrap - see attached Sad

I've been looking at manipulating the DOM after load with some success; I add a known css class to the elements I want to span, then after load look for that class and perform the manipulation:

Code:
...
function colspanFormatter(cssClass, cols) {
    $('.' + cssClass).closest('tr').each(function() {
        for (var c = cols - 1; c > 0; c--) {
            $(this).children('td').eq(c).remove();
        }
        $(this).children('td').eq(0).attr('colspan', cols.toString());
        $(this).children('td').eq(0).children(0).width('100%');
        $(this).removeClass(cssClass);
    });
};
...
$(function(){
    ...
    onLoadSuccess: function (row, data) { colspanFormatter('colspan3', 3); }
...

see demo: http://code.reloado.com/efobob4/edit#preview

This wraps nicely Smiley
But doesn't align very well on at the left Sad
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: May 02, 2018, 11:27:20 PM »

This example works well.
http://code.reloado.com/upuwoq3/2/edit
Logged
pjobbins
Newbie
*
Posts: 4


View Profile
« Reply #4 on: May 03, 2018, 07:25:52 PM »

That works perfectly stworthy, thank you  Smiley
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!