slickgrid滚动跳回顶行

时间:2014-08-25 22:28:36

标签: jquery slickgrid

当我尝试滚动时,在滚动时,网格会将顶行重置为第一行。它拒绝让我向下滚动,它只是跳回到第一行。我已经包含了下面的代码,如果有人能指出原因,我一定会很感激。

function setGrid(d){
    var grid;
    var data = d;
    var columns = [
        { id : "questiontext", name: "Question", field : "QuestionText", sortable:true, behavior:"select", cssClass: "cell-selection", width:620, cannotTriggerInsert:true, formatter: formatgridInActiveDel},
        { id : "isactive", name: "Active", field : "IsActive", sortable:false, behavior:"select", cssClass: "cell-selection", width: 55, cannotTriggerInsert:true, formatter: chkboxFormatter},
        { id : "multianswer", name: "Multi Answer", field : "MultiAnswer", sortable:false, behavior:"select", cssClass: "cell-selection", width: 100, cannotTriggerInsert:true, formatter: chkboxFormatter},
        { id : "orderorq", name: "Order", field : "OrderOfQ", sortable:true, behavior:"select", cssClass: "cell-selection", width: 55, cannotTriggerInsert:true, formatter: formatgridcentercol},
        { id : "btnedit", name: "Edit", field : "Edit", sortable:false, behavior:"select", cssClass: "cell-selection", width: 55, cannotTriggerInsert:true, formatter: buttonFormatter},
        { id : "btndel", name :"Del", field: "Del", sortable:false, behavior:"select", cssClass: "cell-selection", width: 55, cannotTriggerInsert:true, formatter: buttonFormatter}
    ];
    var options = {
        enableCellNavigation: true,
        forceFitcolumns: true,
        multiSelect: false,
        syncColumnCellResize: true
    };
    dataView = new Slick.Data.DataView();
    grid = new Slick.Grid("#questiongrid", dataView, columns, options);
    var pager = Slick.Controls.Pager(dataView, grid, $("#questionpager"));

    grid.setSelectionModel(new Slick.RowSelectionModel());
    grid.onClick.subscribe(function (e, args){
        e.stopPropagation();
        var cell = grid.getCellFromEvent(e);
        var col = grid.getColumns()[cell.cell];
        var item = dataView.getItem(args.row)

        EditDelQuestion(item, col.field)
    });
    dataView.onRowsChanged.subscribe(function(e, args){
        grid.invalidateRows(args.rows);
        grid.render();
    });
    grid.onSort.subscribe(function (e, args) {
        slickGridSort(args.sortCol.field, args.sortAsc, grid, dataView);
    });
    dataView.beginUpdate();
    dataView.setPagingOptions({ pageSize: 12 });
    dataView.setItems(data, "TestQGridid");
    dataView.endUpdate();

}

1 个答案:

答案 0 :(得分:0)

您缺少订阅

dataView.onRowCountChanged.subscribe(function (e, args) {
  grid.updateRowCount();
  grid.render();
});