Textbox for inline edit and Dropdown for dialog edit

QuestionsTextbox for inline edit and Dropdown for dialog edit
Anonymous asked 5 years ago

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?

1 Answers
Abu answered 5 years ago

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

Your Answer

9 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?