Darren Sadr Darren Sadr - 1 year ago 95
Javascript Question

How to display a "Select" element in JQGrid, when not in Edit mode?

I'm aware of the

option, however, in order to see the Select, the user has to initiate an editing.

Instead, I just want the drop-down list to be displayed in the cell by default without the user having to start Editing.

What I've tried:
The html is returned from the the PHP function called by jQGrid AJAX:


And I set the formatter of the column to "select"

How do I accomplish this?

Answer Source

I did the sneakiest thing I have ever done in my life:
I changed the '<' characters to &lt; and changed the '>' characters to &gt; on the server side data.
This way, the data wouldn't be stripped of tags when received by jqgrid.
Then I made a custom formatter in which it replaced the html code with the actual characters, causing the data to be displayed correctly.

formatter: function(cellvalue, options, rowObject){ return cellvalue.replace("&lt;","<").replace("&gt;",">"); } 

Boom! Done deal.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download