0

I have a jqgrid table that has a username and password column, and if I could add automatic selection of a cell's entire contents when the cell is clicked, that would be of great benefit to those who use the table for their work.

Here is what I have so far:

$("#theTable").jqGrid({
            [...]
            colNames:[[...],'Username', 'Password',[...],
            colModel:[
                [...]
                {name: 'username', index: 'username', width: 110, sorttype: 'text', cellattr: function () {return 'class="selectcell"'}},
                {name: 'password', index: 'password', width: 110, sorttype: 'text', cellattr: function () {return 'class="selectcell"'}},
                [...]
            ],
        });

Then later on...

$(".selectcell").click(function(){
    this.select();
});

I took that $.click() from code that automatically selects an entire textbox whenever it is clicked on. It functions perfectly there, but it isn't working as is. How can I make this work?

ZAD-Man
  • 1,328
  • 23
  • 42

1 Answers1

0

It seems that you don't use any editing of the grid. You can add cellEdit: true in the situation. The option allowed to edit cells of columns which have editing: true property. Cell editing have one more important feature. It highlight the cell of all non-editable columns. Because all columns are not editable in your case then you will have the feature highlighting of cells just by adding cellEdit: true option.

If you do need to select the text in the cell then I would recommend you to read the old answer (see the demo) which demonstrates how to select the text inside of clicked cell on double-click.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798