Search code examples
javascriptpaginationgriddhtmlx

DHTMLX - After pagination, Click on Grid redirects to Page 1


I'm using DHTMLX Pro and rendering the table with these configuration. Pagination works fine. After pagination when I click on any row or any cell in the Grid, it is automatically redirecting to the Page 1.

For example: When I'm in page 2, when I click on a grid row in page 2, It goes back to page 1.

grid.js

var per_page = 50;
var $spinner_el = $("#spinnerDiv");   
feedgrid = new dhtmlXGridObject('grid-region');
feedgrid.setImagePath('../../../../static/styles/vendor/dhtmlx/imgs/');
feedgrid.setSkin("dhx_web");
feedgrid.setHeader(["ID","Name","date"]);                 
feedgrid.setColumnIds("id,name,createdDate");
feedgrid.setColTypes("txt,txt,txt");
feedgrid.enableAutoHeight(true);
feedgrid.enableAutoWidth(true);
feedgrid.setEditable(false);
feedgrid.enablePaging(true, per_page, per_page, "pagingArea", true, "infoArea");
feedgrid.setPagingSkin("toolbar", "dhx_web");
feedgrid.init();
feedgrid.load("/getdata", "js");

feedgrid.entBox.onselectstart = function () {
   return true;
};

feedgrid.attachEvent("onXLS", function () {
   spinUtil.on($spinner_el);
});

feedgrid.attachEvent("onXLE", function () {
  spinUtil.off($spinner_el);
  resizeGrid();
});

feedgrid.attachEvent("onRowInserted", function (rId) {
  feedgrid.adjustColumnSize(0);
  feedgrid.adjustColumnSize(1);
  feedgrid.adjustColumnSize(2);
});

feedgrid.attachEvent("onResizeEnd", function (cInd, cWidth, obj) {
  resizeGrid();
});

feedgrid.attachEvent("onPageChanged", function (ind, fInd, lInd) {
  resizeGrid();
});

html

    <div id='grid-region'></div>
    <div class="loading-image" id="table-ajax-loader"></div>
    <div class="paginate-head">
        <div id="pagingArea"></div>
        &nbsp;
        <div id="infoArea"></div>
    </div>

Not sure what is wrong.


Solution

  • I had to override onBeforeSelect DHTMLX event to disable the redirection to page 1,

    ingestionGrid.attachEvent("onBeforeSelect", function(new_row,old_row,new_col_index){
        //alert(new_row);
    });