EasyUI Forum
May 04, 2024, 04:25:10 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: No horizontal scrollbar in datagrid  (Read 15749 times)
hande89
Jr. Member
**
Posts: 56


View Profile
« on: July 29, 2014, 12:52:15 AM »

http://jquery-easyui.wikidot.com/forum/t-352646/datagrid-does-not-appear-horizontal-scrollbar

This bug is still there. I have exactly the same problem. No horizontal scrollbar is displayed when datagrid where width is fixed receives an empty data array. Tried the newest datagrid version from http://www.jeasyui.com/easyui/plugins/jquery.datagrid.js but its not working.
« Last Edit: July 29, 2014, 01:00:27 AM by hande89 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 29, 2014, 02:08:58 AM »

Here is the simple way to solve this issue. Extend a view and apply it to the datagrid.
Code:
var myview = $.extend({},$.fn.datagrid.defaults.view,{
onAfterRender:function(target){
$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
var dg = $(target);
if (dg.datagrid('getRows').length == 0){
setTimeout(function(){
dg.datagrid('appendRow',{});
dg.datagrid('options').finder.getTr(target, 0).css('height',0);
},0)
}
}
});
$(function(){
$('#dg').datagrid({
view: myview,
data:[]
})
})
Logged
hande89
Jr. Member
**
Posts: 56


View Profile
« Reply #2 on: July 30, 2014, 04:58:34 AM »

I have to use datagrid detail view. http://www.jeasyui.com/easyui/datagrid-detailview.js

If I apply your code there, the expand button is displayed even if no rows exist.


The scrollbar is also not displayed on treegrid with 0 nodes.
« Last Edit: July 30, 2014, 05:55:07 AM by hande89 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 30, 2014, 06:40:03 PM »

If you are using 'detailview', please extend from detailview instead of extending from the default datagrid view.
Code:
var myview = $.extend({},detailview,{
onAfterRender:function(target){
detailview.onAfterRender.call(this,target);
var dg = $(target);
if (dg.datagrid('getRows').length == 0){
setTimeout(function(){
dg.datagrid('appendRow',{});
dg.datagrid('options').finder.getTr(target, 0).css('height',0).find('*').css('height',0);
},0)
}
}
});
Logged
ryupanqui
Newbie
*
Posts: 44


View Profile Email
« Reply #4 on: July 31, 2014, 02:07:33 PM »

i have the same problem when the datagrid is empty. stworthy, are you planning to include this solution in the $.fn.datagrid.defaults.view as default behavior?
Logged
omhardb
Newbie
*
Posts: 11


View Profile Email
« Reply #5 on: July 31, 2014, 02:15:53 PM »

I also have the same request. I need that datagrid have this behavior as default in the jeasyui library. Are you planning to incluide it in?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #6 on: August 01, 2014, 12:23:37 AM »

The default behavior can be overridden as below:
Code:
(function($){
var onAfterRender = $.fn.datagrid.defaults.view.onAfterRender;
$.extend($.fn.datagrid.defaults.view, {
onAfterRender:function(target){
onAfterRender.call(this,target);
var dg = $(target);
if (dg.datagrid('getRows').length == 0){
setTimeout(function(){
dg.datagrid('appendRow',{});
dg.datagrid('options').finder.getTr(target, 0).css('height',0).find('*').css('height',0);
},0)
}
}
});
})(jQuery);
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!