Skip to content

Dynamic Details Grid Caption

Problem:


How to set the title of the detail grid dynamically with id from the selected row in master grid? 

Solution:


Use event handler "jqGridSelectRow"

Code snippet attached. 

// Set detail grid title with selectRow event
$selectRow = <<<SELECTROW
function(status, row_id) {

    var gview_row_id = '#gview_orders_d1';

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

$dg->add_event("jqGridSelectRow",$selectRow);

Note that above detail grid caption has the ID gview_orders_d1, where orders is the table name of master table; and d1 is the first detail grid sequence, the second detail grid would have a sequence d2, and so forth. 

In other words, the detail grid caption's ID has the format "gview_<master table name>_dn". 



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

Feedback and Knowledge Base