0

我正在尝试在 jqgrid(4.9.2)上使用 mCustomScrollbar。滚动条的设计正在发生变化,但是当水平滚动时,顶部标题不会像往常一样移动。我正在尝试处理的示例是可折叠网格。对于 mCustomScroll

$(".ui-jqgrid-bdiv").mCustomScrollbar({
    axis:"yx",
});

根本不可能在 jqgrid 上使用任何自定义滚动条吗?

4

1 回答 1

0

I had made some customized changes to jqgr so migrating to the other version will be a tough task, so Instead, I made the changes in the mcustomscrollbar and posting the answer so if any one else come across the same problem it will be beneficial. so there is a methods _tweetTo, which is called for the container on which the scrollbar is assigned by the initializing as

$(".ui-jqgrid-bdiv").mCustomScrollbar({
    axis:"yx",
}); 

now just after the method call _tweenTo(line# 2131 for V:3.1.5) insert the following code

if ($(".ui-jqgrid-hdiv").length > 0) {

                    $(".ui-jqgrid-view").css("overflow", "hidden");
                    $(".ui-jqgrid-hdiv").css("width", $("#grid1").width() + "px"); // grid1 is the id of your gridcontainer/table
                    _tweenTo($(".ui-jqgrid-hdiv")[0], property, Math.round(scrollTo[0]), dur[0], options.scrollEasing, options.overwrite, {
                        onStart: function () {
                            if (options.callbacks && options.onStart && !d.tweenRunning) {
                                /* callbacks: onScrollStart */
                                if (_cb("onScrollStart")) { _mcs(); o.callbacks.onScrollStart.call(el[0]); }
                                d.tweenRunning = true;
                                _onDragClasses(mCSB_dragger);
                                d.cbOffsets = _cbOffsets();
                            }
                        }, onUpdate: function () {
                            if (options.callbacks && options.onUpdate) {
                                /* callbacks: whileScrolling */
                                if (_cb("whileScrolling")) { _mcs(); o.callbacks.whileScrolling.call(el[0]); }
                            }
                        }, onComplete: function () {
                            if (options.callbacks && options.onComplete) {
                                if (o.axis === "yx") { clearTimeout(mCSB_container[0].onCompleteTimeout); }
                                var t = mCSB_container[0].idleTimer || 0;
                                mCSB_container[0].onCompleteTimeout = setTimeout(function () {
                                    /* callbacks: onScroll, onTotalScroll, onTotalScrollBack */
                                    if (_cb("onScroll")) { _mcs(); o.callbacks.onScroll.call(el[0]); }
                                    if (_cb("onTotalScroll") && scrollTo[1] >= limit[1] - totalScrollOffset && d.cbOffsets[0]) { _mcs(); o.callbacks.onTotalScroll.call(el[0]); }
                                    if (_cb("onTotalScrollBack") && scrollTo[1] <= totalScrollBackOffset && d.cbOffsets[1]) { _mcs(); o.callbacks.onTotalScrollBack.call(el[0]); }
                                    d.tweenRunning = false;
                                    mCSB_container[0].idleTimer = 0;
                                    _onDragClasses(mCSB_dragger, "hide");
                                }, t);
                            }
                        }
                    });
                }

and in the method definition of _tweenTo there is another method _tween update that method as

 function _tween() {
                    // added condition so the top headers remains fixed
                    if (el.classList.contains("ui-jqgrid-hdiv") && prop == "top") {
                        return;
                    }
                    //ends here 
                    if (duration > 0) {
                        tobj.currVal = _ease(tobj.time, from, diff, duration, easing);
                        elStyle[prop] = Math.round(tobj.currVal) + "px";
                    } else {
                        elStyle[prop] = to + "px";
                    }
                    onUpdate.call();
                }

and the scrollbar is up and running.. !!

于 2017-08-01T12:27:11.317 回答