I have specified userdata
in JSON response. Depending on the value of the title
property,
There are no methods for changing of content top or bottom toolbars added by toolbar
option of jqGrid, but you can use setCaption
to set grid caption (title). The small modified demo of your code uses the following loadComplete
:
loadComplete: function () {
var $this = $(this), userdata = $this.jqGrid('getGridParam', 'userData');
if (userdata && userdata.title) {
$this.jqGrid('setCaption', userdata.title);
}
if (userdata.title === "My Title 1") {
$this.jqGrid('setCaption', "Viewing the Records.");
$('#t_' + $.jgrid.jqID(this.id))
.append('<div style="margin: 0.3em">Viewing the Records.</div>');
} else if (userdata.title === "My Title 2") {
$this.jqGrid('setCaption', "Editing the Records.");
$('#t_' + $.jgrid.jqID(this.id))
.append('<div style="margin: 0.3em">Editing the Records.</div>');
}
}
The usage of $.jgrid.jqID(this.id)
instead of this.id
is helpful in the case if the id
of the grid (in you case 'myjqgrid') contains some meta-characters.