Hi.
I have a column where in the main grid I want to use a text field, but in the add/edit form I want to use a dropdown. Setting $col[‘formatter’] = ‘select’ breaks the main grid when I search. Is there any way to target only the forms?
You can use afterShowForm event and replace input text to dropdown using jquery. e.g.
$opt[“edit_options”][“afterShowForm”] = ‘function (form)
{
var str = \'<select role=”select” class=”FormElement ui-widget-content ui-corner-all” name=”client_id” id=”client_id”><option value=”1″>One</option><option value=”2″>Two</option></select>\’;
jQuery(“#tr_”+”client_id”+” td.DataTD input”).replaceWith(str);
}’;
$g->set_options($opt);
Replace “field” with your actual field name specified in $col[“name”]. To have same thing for add dialog, also set it for $opt[“add_options”][“afterShowForm”].
Demo code here: https://gist.github.com/8a49d68d1a1ed06e91df2858bf447edc