EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Opan Mustopah on February 05, 2015, 07:25:06 PM



Title: horizontal scrollbar not showing on datagrid when data is empty
Post by: Opan Mustopah on February 05, 2015, 07:25:06 PM
hello again.

i have a datagrid with property fitColumns is false which allow datagrid to scroll horizontal.
when datagrid have a data at least one, the horizontal scrollbar appear, but when data is empty the horizontal scrollbar is dissappear.

how to make it always show even datagrid doesn't have a data?

many thanks for the answer


Title: Re: horizontal scrollbar not showing on datagrid when data is empty
Post by: Opan Mustopah on February 06, 2015, 10:25:45 PM
is there no solution for this ?


Title: Re: horizontal scrollbar not showing on datagrid when data is empty
Post by: stworthy on February 07, 2015, 01:25:08 AM
Please refer to this topic http://www.jeasyui.com/forum/index.php?topic=3600.0


Title: Re: horizontal scrollbar not showing on datagrid when data is empty
Post by: Opan Mustopah on February 07, 2015, 01:36:44 AM
thanks stworthy for your response, but i already use scrollview.
in your example, it's override the current view on datagrid.

how to achieve it on scrollview ?


Title: Re: horizontal scrollbar not showing on datagrid when data is empty
Post by: stworthy on February 07, 2015, 08:12:21 AM
This code also works in scrollview.
Code:
(function($){
$.fn.datagrid.defaults.data = [];
var onAfterRender = $.fn.datagrid.defaults.view.onAfterRender;
$.extend($.fn.datagrid.defaults.view, {
onAfterRender:function(target){
onAfterRender.call(this,target);
var dg = $(target);
var data = dg.datagrid('getData');
if (data.rows.length == 0){
setTimeout(function(){
dg.datagrid('appendRow',{});
dg.datagrid('options').finder.getTr(target, 0).css('height',0).find('*').css('height',0);
data.total = 0;
data.rows = [];
},0)
}
}
});
})(jQuery);


Title: Re: horizontal scrollbar not showing on datagrid when data is empty
Post by: Opan Mustopah on February 07, 2015, 08:19:50 AM
thanks stworthy, i'll try it ASAP