Adding a button to a row in jqgrid

前端 未结 5 1077
日久生厌
日久生厌 2021-02-04 04:59

I want to add a button to each row in my grid that will bring up a new window. Do not see this feature in this very rich control. Must be missing something

5条回答
  •  余生分开走
    2021-02-04 05:23

    I am using a jqgrid to display a list of contacts. I have a column named 'Role' with a button that says 'Define', such that you can click on it and redefine that contact's role as primary, secondary, sales, or other.

    Originally, the button element was being sent to the grid cell via XML, where $rowid was the id of the row (PHP):

    Define]]> 
    

    This worked fine until I set autoencode: true on the grid. With this option set to true, the column was simply displaying the html.

    Craig's answer displayed similar behavior, but a slight variation of it did the trick. I thought I'd share:

    gridcomplete: function() {
        var ids = $grid.getDataIDs();
    
        for (var i=0;iDefine';
            if (cl.substr(0,2) !== "jq") {
                $('#'+cl).find('td[aria-describedby="list_role"]').html(button);
            }
        }
    }
    

    In other words, the setRowData method didn't work with autoencode set to true, but the DOM can be manipulated as desired within the gridcomplete event.

提交回复
热议问题