ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: twz on May 08, 2014, 05:55:48 am

Title: Highlight cell contents on edit
Post by: twz on May 08, 2014, 05:55:48 am
When a cell is selected for editing, the cursor appears at the start of the text. If you want to replace the text you need to delete the current contents first.

I would like the current contents to be highlighted automatically, so I can just start typing to replace the contents.

I'm surprised there doesn't seem to be an option for this - and nobody seems to have mentioned it before - or am I missing something obvious?
Title: Re: Highlight cell contents on edit
Post by: paramvir on May 08, 2014, 07:18:44 pm
selection of text in editor is inbuilt only in PRO using a simple parameter

however you can write your own method to do it.

$grid.on( "focus", "input,textarea,div[contenteditable=true]",  function(evt){
  //code here to select text of $(this)
});

http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
Title: Re: Highlight cell contents on edit
Post by: twz on May 09, 2014, 07:43:11 am
Thanks for your reply.

I struggled with this for a while, but got it working eventually. Note: I had to select the text of 'this', not '$(this)'
Title: Re: Highlight cell contents on edit
Post by: twz on May 18, 2014, 05:31:17 am
Just to clarify - the reason I needed 'this' and not '$(this)' is that the code I used from your link was pure Javascript - so it was expecting a DOM element, not a jQuery object.