0
votes

I am using jqGrid in inline editing mode.

For a particular grid, I need that when I edit a row for some of the values to be displayed in the fields and for others to not.

For example I have a row with these values:

col1 : 8h ; col2 : 8h ; col3 : 8h ; col4 : V ; col5 : V ; col6 : V ; col7 : 8h ; col8 : 8h

When I click edit the row, I need it that when there is an "8h" in the cell the fields will be empty, and when there is "V" in the cell the fields will keep the "V".

I tried to use this response of Oleg: response But I am not able to distinguish the "8h" and the "V"

1

1 Answers

0
votes

I am not sure that I correctly understand your requirements. I suppose that you can change the line

$("input:text", $tr).val('');

from the code of the answer to something like

$("input:text", $tr).filter(function() {
    return /^8h$/i.test($(this).val())
}).val("");

The expression /^8h$/i is the regular expression where

  • ^ means matching the begin of the testing string
  • $ means matching the end of the testing string
  • /i at the end of the regular expression means case insensitive compare

So the above filter tests values of <input> elements and choose only the elements which contains is 8h or 8H. You can remove i at the end of the regular expression if you need case sensitive compare.