Reputation: 5238
Anyone know if its possible to set an image in one of the column headers of the jqgrid?
I have tried the following:
$("#jqgh_Jqgrid_1_t_TEST").prepend("<img src='...' alt='test' />");
I think this may work, but when should the function be called?
Upvotes: 2
Views: 3182
Reputation: 134157
As Piyush mentioned, this can be done using the setLabel
method. From the method documentation:
setLabel
colname, data, class, properties
Sets a new label in the header for the specified column; can also set attributes and classes . The parameters are:
- colname the name of the column (this parameter can be a number (the index of the column) beginning from 0
- data the content that can be put into the label. If empty string the content will not be changed
- class if class is string then we add a class to the label using addClass; if class is an array we set the new css properties via css
- properties sets the attribute properies of the label
And here is an example of how you can use setLabel
to display an image:
jQuery(myGrid).jqGrid('setLabel',
'myColName',
'<img src=images/my-image.png width=16 height=16>');
You might want to set the height to around 16 pixels so it has the same height as your grid text, as in this example, but that is entirely up to you.
Upvotes: 4