How to set grid column header caption?

I have a checkbox field with a long name, so when I add this field to a grid, the column takes up a ton of unnecessary space.  It seems the client-side API supports access to the grid's columns, rows and cells collections, but not to the grid's header objects.  I've tried the following JavaScript (added to Custom Content) on the Opportunity Grid.  When I click Find on the grid, the alert correctly pops up and displays Assigned To, so I know the 1st line of the function is correctly capturing the header text.  The problem is that the 2nd line is never called as the header caption remains unchanged.  Any thoughts or suggestions?  Thanks.


     <script type="text/javascript">
          $(document).ready(function(){
               var o = document.getElementById("_Captoppo_assigneduserid").innerHTML;
               alert("o=" + o);
               document.getElementById("_Captoppo_assigneduserid").innerHTML = "PM";
            });
     </script>

  • Grid column headers have no ID, your getElementById is probably looking at a filter field on the right.
    Column headers have a "colname" property you can use to get the right element.

    You can set the text of a column header using this example:
    $("td[colname=oppo_assigneduserid]").text("abcd");

  • Thanks so much John!  This is a bit embarrassing, but when I did a View Source to examine the HTML, I searched for the text of my column header.  My searched returned a result, but what I didn't realize is that the result returned was for the field in the SearchBox - i.e. the panel at the top of the form, not the col header in the Grid at the bottom of the form.  If only I had hit FIND NEXT.  Oh well, as I say, I greatly appreciate your help!