Skip to content

Dynamic Subgrid Caption

Problem:


Is there a way to dynamically change the subgrid caption based on the selected row of the master grid?

Solution:


With event handler "jqGridSubGridRowExpanded", it can do just exactly that.

See code snippet below. Note s0 is the id of the first subgrid

// Set subgrid title with expand event
// row_id is the id of the row e.g. orders_10100
// s0 is the id of the first subgrid e.g. orders_10100_s0
$subgridRowExpanded = <<<SUBGRIDROWEXPANDED
function(subgrid_id, row_id) {

    var gview_row_id = '#gview_'+ row_id + '_s0';

    setTimeout(function(){
        $(gview_row_id + ' > div.ui-jqgrid-titlebar').text(row_id)
    },100);
}
SUBGRIDROWEXPANDED;

$dg->add_event("jqGridSubGridRowExpanded",$subgridRowExpanded);
$dg-> display();




More custom event handler examples: https://phpgrid.com/example/custom-event-handler/

Feedback and Knowledge Base