Show the text select when a field of a record get focus on the grid.

QuestionsShow the text select when a field of a record get focus on the grid.
Montemaggiore Sebastian asked 10 years ago

Hello. when you press <TAB> the focus moves between the fieds of a record. Now, how can i do to select the text automatically the text of the field?.
Thanks.

8 Answers
Abu Ghufran answered 10 years ago

You can set: $col["editoptions"]["onfocus"] = "this.select();";

$col = array();
$col["title"] = "Gender";
$col["name"] = "gender";
$col["width"] = "30";
$col["editable"] = true;
$col["editoptions"]["onfocus"] = "this.select();";
$cols[] = $col;

Montemaggiore Sebastian answered 10 years ago

Hello. It doesn´t work. I look for $col["editoptions"]["onfocus"] in jqgrid_dist.php and i can´t find it.
Thanks.

Abu Ghufran answered 10 years ago

In following demo, click on row > edit from toolbar > tab to gender field.

Live: http://www.phpgrid.org/demo/demos/appearence/group-headers.php
Code: http://www.phpgrid.org/demo/demos/appearence/group-headers.phps

Montemaggiore Sebastian answered 10 years ago

Hello.It doesn´t work yet. The version if the file jqgrid_dist.php that i have is @version 1.5.2 build 20140707-0413. Besides, i can´t find where is implemented the event ONFOCUS.
Thanks for your help.

Montemaggiore Sebastian answered 10 years ago

I want to add that i implement the code as you show me in the demo. I seems that the grid doesn´t know the event.
Thanks.

Abu Ghufran answered 10 years ago

Grid internally translates editoptions array keys to input element attributes, so onfocus is handler by this rule.
You can put alert('test') statements there to show the effect.

Montemaggiore Sebastian answered 10 years ago

Hello. I find that when the field is of type text it works, but when the type is textarea it doesn´t. Can you tell me why?.
Thanks aganin for your help!!.

Montemaggiore Sebastian answered 10 years ago

First of all i must apoligize!!.I was making a mistake, objects of type textarea don´t work the same as thats of type text.
This:
$col["editoptions"]["onfocus"] = "this.select();";
will not work because the standart doesn´t allow.
So my solution was:
$col["editoptions"]["onclick"] = "this.focus(); this.select();";
Thanks.

Your Answer

10 + 7 =

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?