EasyUI Forum

General Category => Bug Report => Topic started by: itay-g on August 20, 2014, 01:45:56 AM



Title: TreeGrid : Can't scroll columns when there no rows
Post by: itay-g on August 20, 2014, 01:45:56 AM
Hello!

A scroll doesn't appear in the TreeGrid unless there is a row,
for example :
When there are no rows in the TreeGrid,
and the columns extend over the panel's size, you can't see some of the columns and a scroll doesn't appear until there are rows in the grid, meaning you can't look at all the columns.


Title: Re: TreeGrid : Can't scroll columns when there no rows
Post by: jarry on August 21, 2014, 12:53:38 AM
Please try to override the treegrid view to solve this issue.
Code:
<script>
(function($){
render = $.fn.treegrid.defaults.view.render;
$.extend($.fn.treegrid.defaults.view, {
render: function(target, container, frozen){
$(container).children('table.datagrid-btable-stub').remove();
render.call(this, target, container, frozen);

var state = $.data(target, 'treegrid');
var dc = state.dc;
if (dc.body2.is(':empty')){
var fields = $(target).treegrid('getColumnFields', frozen);
var table = ['<table class="datagrid-btable-stub" cellspacing="0" cellpadding="0" border="0"><tbody>'];
table = table.concat(this.renderRow.call(this, target, fields, frozen, 0, {}));
table.push('</tbody></table>');
$(container).html(table.join(''));
$(container).find('div').height(0);
}
}
})
})(jQuery);
</script>


Title: Re: TreeGrid : Can't scroll columns when there no rows
Post by: hande89 on August 21, 2014, 01:42:32 AM
I have the same problem. Solution seems to be working on page load but not if client side filtering returns 0 rows.


Title: Re: TreeGrid : Can't scroll columns when there no rows
Post by: itay-g on September 07, 2014, 03:57:53 AM
Hey jarry,
the solution worked, but it created various other problems since the grid now has a "fake" row - which for examples causes RenderRow to call the styler of that row, which causes an exception in our code since the row being sent is simply empty. The same happened in various other places.

Is there another possible fix for this problem?
Thank you.


Title: Re: TreeGrid : Can't scroll columns when there no rows
Post by: jarry on September 07, 2014, 08:18:48 AM
No matter what styles are applied to this hidden row, it does not affect the user to operate the treegrid since the row is hidden. You must make sure that your 'styler' code can run well on any working environments even encountering an empty row.