滚动网格有时不会在extjs中重新加载

时间:2014-11-10 02:09:16

标签: extjs

我有一个网格并在网格中滚动。这是我生成网格的代码

gridMain = Ext.create('Ext.grid.Panel', {
        renderTo: Ext.get("sa-grid"),
        store: 'pf-store',
        height: mainContentHeight - 63,
        title: 'Promotion Form',
        columns: [{
            text: 'No PF',
            width: 115,
            dataIndex: 'PFID'
        },
        {
            text: 'Title',
            flex: 1,
            dataIndex: 'Title'
        },
        {
            text: 'Promotion From',
            dataIndex: 'PromotionFrom'
        },
        {
            text: 'Promotion To',
            dataIndex: 'PromotionTo'
        },
        {
            text: 'Limit Payment Date',
            width: 120,
            dataIndex: 'LimitPaymentDate'
        },
        {
            text: 'Request Status',
            width: 150,
            dataIndex: 'RequestDescription'
        },
        {
            text: 'Initiator',
            width: 150,
            dataIndex: 'CreateByName'
        }],
        dockedItems: [{
            xtype: 'toolbar',
            items: [actAddPF, actEditPF, actDeletePF, actExtendPF]
        }],
        listeners: {
            itemdblclick: function (view, record, item, index, e, eOpts) {
                isGridClicked = true;
                ViewDetails(FormState.VIEW);
            }
        }
    });


function ViewDetails(FormState) {
        var data = GetSelectedRecord(gridMain);
        var id = data.PFID;
        ShowLoading("sa-body", "Please Wait ...");
        $.ajax({
            type: 'POST',
            url: root + "PF/GetDataByID",
            data: { PFID: id },
            success: function (result) {
                try {
                    DataToArray(result);
                    DataToControl(result);
                    CreatePivotPeriode();
                    CreateMainPivot();
                    ChangeFormState(FormState);
                    tabs.setActiveTab('pageDetails');
                } catch (err) {
                    MsgErr(err);
                }
            },
            complete: function () {
                try {
                    HideLoading();
                } catch (err) {
                    MsgErr(err);
                }
            }
        });
    }

它工作正常,但是当我插入或修改数据并再次加载或单击按参数搜索时。滚动不起作用。网格中的内容是基于搜索参数更新的,问题只是不再工作的滚动。然后我必须做F5再次刷新它,以便网格可以再次滚动。

这是我在网格中搜索的代码

   $("#btnSearch").click(function () {
        ShowLoading("sa-body", "Please Wait ...");
        $.post(root + "PF/Search", { FieldName: $("#cbSearch").val(), Pattern: $("#cbPattern").val(), Condition: $("#txtSearch").val() }, function (data) {
            storePF.loadDataViaReader(data);
            HideLoading();
        });
    });

有人有解决此问题的方法吗? 非常感谢

1 个答案:

答案 0 :(得分:0)

我能做到这一点 :)

Ext.override(Ext.grid.Scroller, {
    onAdded: function() {
        this.callParent(arguments);
        var me = this;
        if (me.scrollEl) {
            me.mun(me.scrollEl, 'scroll', me.onElScroll, me);
            me.mon(me.scrollEl, 'scroll', me.onElScroll, me);
        }
    }
});