Is a Footer row in a jqgrid selectable/clickable?

后端 未结 3 762
不知归路
不知归路 2021-01-23 16:59

I have a jqgrid that has main rows and a footer row (with userdata loaded) and then a formatter that alters the data in the cells to be linkable. The cells in the main body can

3条回答
  •  北海茫月
    2021-01-23 17:41

    jqGrid registers click event on main

    of the grid, but it calls onCellSelect not always. First of all (see here) it tests some additional conditions and then returns (ignore click event) if the conditions failed. For example if one clicks on grouping headers of the grid the callback onCellSelect will not be processed.

    The problem with footer row because it exists outside of the grid. The main

    element are placed inside of div.ui-jqgrid-bdiv, but the footer is inside of another table which is inside of div.ui-jqgrid-sdiv. One can examine the HTML structure of jqGrid using Developer Tools of Internet Explorer, Google Chrome, Firebug or other. One will see about the following

    enter image description here

    The main

    element (
    in the picture above and which get the class "ui-jqgrid-btable") and another table element with the footer (which get the class "ui-jqgrid-ftable") are separate.

    So the fist answer of Mark on your question was correct. If one has multiple grids on the page one could specify footer of specific grid using

    var $grid = $('#jqgSummaryResults'); // one specific grid
    
    .... // here the grid will be created
    
    $grid.closest(".ui-jqgrid-view").find(".ui-jqgrid-sdiv").click(function() {
        // do in case of the footer is clicked.
        var $td = $(e.target).closest("td"),
            iCol = $.jgrid.getCellIndex($td); // or just $td[0].cellIndex,
            colModel = $grid.jqGrid("getGridParam", "colModel");
    
       // $td - represents the clicked cell
       // iCol - index of column in footer of the clicked cell
       // colModel[iCol].name - is the name of column of the clicked cell
    });
    

    P.S. In the old answer are described many other elements of the grid. The descriptions are not full, but it could be probably helpful.

    提交回复
    热议问题