开发者

Paging in slickGrid

I was able to utilize paging in slickGrid however I am new to jquery and slickGrid and can't get to move in between pages. can anyone help me with this? Any help is greatly appreciated. Thanks!

$(document).ready(function() {var columns = [
{id:"counter", name:"#",field:"counter"},
{id:"data1", name:"Data 1",field:"data1"},
{id:"data2", name:"Data 2",field:"data2"},
{id:"data3", name:"Data 3",field:"data3"},
{id:"data4", name:"Data 4",field:"data4"}];

var options = { enableCellNavigation: false,
enableColumnReorder: false};

var FB_C_grid;
var FB_C_data;
var selectedRowIds = [];
var dataView;

$(function() {
FB_C_data = []; 
FB_C_data[0]={"id":"0",
"data1":"test1",
"data2":"test1",
"data3":"test1",
"data4":"test1,
"counter":"1"
}; 

for (var i=1; i<50000; i++) {
    var d = (FB_C_data[i] = {});enter code here

    d["id"] = "id_" + i;
    d["data1"] = "data1_" + i;
    d["data2"] = "data2_" + i;
    d["data3"] = "data3_" + i;
    d["data4"] = "data4_" + i;
                d["counter"] = i;
   }


    dataView = new Slick.Data.DataView();
    dataView.setItems(FB_C_data);
    dataView.setPagingOptions({pageSize:20});
    FB_C_grid= new Slick.Grid($("#FB_C_sheet"),dataView.rows, columns,options);
    var pager = new Slick.Controls.Pager(dataView, FB_C_grid, $("#pagerTest"));

    dataView.onRowsChanged.subscribe(function(rows) {
 FB_C_grid.removeRows(rows);
 FB_C_grid.render();

         if (selectedRowIds.length > 0)
    {
     // since how the original data maps onto rows has changed,
     // the selected rows in the grid need to be updated
     var selRows = [];
     for 开发者_如何学Go(var i = 0; i < selectedRowIds.length; i++)
     {
      var idx = dataView.getRowById(selectedRowIds[i]);
      if (idx != undefined)
       selRows.push(idx);
     }

      FB_C_grid.setSelectedRows(selRows);
    }
   });

   dataView.onPagingInfoChanged.subscribe(function(pagingInfo) {
    var isLastPage = pagingInfo.pageSize*(pagingInfo.pageNum+1)-1 >= pagingInfo.totalRows;
                var enableAddRow = isLastPage || pagingInfo.pageSize==0;
                var options = FB_C_grid.getOptions();

                if (options.enableAddRow != enableAddRow)
         FB_C_grid.setOptions({enableAddRow:enableAddRow});
   });

               dataView.onRowCountChanged.subscribe(function(args) {
    FB_C_grid.updateRowCount();
                FB_C_grid.render();
   });

})

  });


I see some of your errors as you are trying to pass a jQuery object into SlickGrid while SlickGrid already uses jQuery in the code behind. When you create your SlickGrid object, you just need to pass the name of your grid and so in your code, you have to replace this $("#pagerTest") without jQuery wrapper becomes this "#pagerTest"

I see you called it the same in 2 different locations, so replace your 2 lines with this:

FB_C_grid= new Slick.Grid("#FB_C_sheet",dataView.rows, columns,options);
var pager = new Slick.Controls.Pager(dataView, FB_C_grid, "#pagerTest");

Hope that helps you make it to work...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜