在ExtJs中更改滚动条
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

I'm using ExtJs and trying to change look of the default scroll-bars (for Grid Panel).

I tried using jScrollPane, but it's not working at all with ExtJs.

Is there any way to change look of default look of scroll-bars in ExtJS. I wont to achieve look similar to jScrollPane

Thanks!

#0

I stumbled across this post while looking to implement jScrollPane on the extjs 4.0.7 grid

I couldn't find anything else suitable, and I now have this terrible hacky way of doing it:

Apply this to your grid config

scroll: false

And this to your grid's viewModel

style: {
    overflow: 'auto',
    'overflow-x': 'hidden'
}

so that the internal scrolling is switched off.

Apply this function to your grid that extends Ext.grid.Panel

reapplyScrollbar: function () {
    var items = $('#' + this.id + ' .x-grid-view');
    var broken = $('#' + this.id + ' .jScrollPaneContainer:not(:first-child)');
    var unbroken = $('#' + this.id + ' .jScrollPaneContainer:first-child');
    console.log('unbroken count=' + unbroken.length);
    console.log('removing ' + broken.length + ' broken containers');
    broken.remove();

    // grid resized so scroller must be removed
    if (items.parent().is('.jScrollPaneContainer') && items[0].parentNode.clientHeight != items[0].clientHeight) {
        console.log('moving el up to grid body');
        var container = items.parent();
        var gridBody = items.parent().parent();
        gridBody.append(items);
        container.remove();

        if (items[0].parentNode.clientHeight != items[0].clientHeight || items[0].parentNode.clientWidth != items[0].clientWidth) {
            items[0].style.height = items[0].parentNode.clientHeight + 'px';
            items[0].style.width = items[0].parentNode.clientWidth + 'px';
            console.log('moved el and reset height & width');
        }

    } else if (items.length > 0 && items[0].clientHeight > 0 && unbroken.length == 0) {
        if (items[0].parentNode.clientHeight != items[0].clientHeight) {
            items[0].style.height = items[0].parentNode.clientHeight + 'px';
            items[0].style.width = items[0].parentNode.clientWidth + 'px';
            console.log('reset height & width');
        }

        console.log('applying scroll');
        items.jScrollPane();
        items[0].style.top = "";
    }
}

The general idea is that layout is called way too many times to know what's going on internally, so we'll check the condition of the grid view. If the grid view has a different height to its container then the jScrollPane needs re-applying (and the old one removing). Internally something happens that means the jScrollPanes get orphaned, so we remove orphaned ones.

When store records are added and removed I'm also calling reapplyScrollbar.

Naturally although this works it is very nasty. Eventually I'll do it somewhere deeper by changing the rendered markup.

#1

I manage to use jscrollpane with extJs GridPanel.

In render listener of Grid Panel I put

$(function(){
    $('.x-grid3-scroller').jScrollPane();
});

推荐文章

SQL分析函数-如何给分区分配数字?

SQL分析函数-如何给分区分配数字?

推荐文章

使用JS的checkbox启用文本框

使用JS的checkbox启用文本框

推荐文章

如何将数据传递给错误处理程序?

如何将数据传递给错误处理程序?

推荐文章

谷歌如何用不同的语言显示一个网站?

谷歌如何用不同的语言显示一个网站?

推荐文章

在BigDecimal中修剪两个以上的尾随零

在BigDecimal中修剪两个以上的尾随零

推荐文章

导航控制器不显示iphone

导航控制器不显示iphone

推荐文章

为什么创建reqpro40.applicationclass的实例失败?

为什么创建reqpro40.applicationclass的实例失败?

推荐文章

使用jQuery将类添加到特定于组的div

使用jQuery将类添加到特定于组的div

推荐文章

访问min.us API

访问min.us API

推荐文章

使用Collections.sort(object)比较长值

使用Collections.sort(object)比较长值

推荐文章

什么是StreamingContextStates.CrossAppDomain?

什么是StreamingContextStates.CrossAppDomain?

推荐文章

Selenium右键单击鼠标或按键盘上的选项键

Selenium右键单击鼠标或按键盘上的选项键

推荐文章

动态内存分配-c语言中原语类型的默认初始化++

动态内存分配-c语言中原语类型的默认初始化++

推荐文章

Mysql:如何在查询中使用CASE

Mysql:如何在查询中使用CASE

推荐文章

连接错误:超时已过期。从池获取连接之前经过的超时时间

连接错误:超时已过期。从池获取连接之前经过的超时时间

推荐文章

PHP/Ruby on Rails SMTP电子邮件验证或检查邮件是否已送达

PHP/Ruby on Rails SMTP电子邮件验证或检查邮件是否已送达