1

I have jqgrid with inline editing mode. What I want to accomplish is when changing cell value, another cell value to be changed too.

What I have for now is:

ondblClickRow: function (id) {
    var selR = $(this).getRowData(id);

    $("#" + $(selR.Inflow).attr("id")).keypress(function () {              
      $(obj.grid).jqGrid("setCell", id, "Inflow", "123321");
 });
}

With this try the cell value is changed but edit mode is disabled after invoking setCell. I want to change it but to stay in edit mode. Any ideas ?

TheChampp
  • 1,337
  • 5
  • 24
  • 41

1 Answers1

2

I would recommend you to define dataEvents property of editoptions of the first column. You can bind change event handler which you define inside of dataEvents. It allows you to monitor the changing of the first column. To access the second column inside of the change event handler you can use jQuery.val method, where you use id selector. You need just to know that ids of all fields on inline editing are build based on the rowid (the id of outer <tr> element) appended with underscore ("_") and the name on the column. The "UPDATED 3" part of the answer provides the demo which do the changes in more common case. To get the rowid from the Event object e you can use $(e.target).closest("tr.jqgrow").attr("id").

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Ok i tried it. The difference between the example and my case is that I use input element type text. After change the value of html inside this element it looks like this Value goes here Despite this the value on the screen stays the same on the same row. Did I miss something ? – TheChampp Nov 29 '15 at 16:29
  • @TheChampp: I wrote in my answer that you should just use `jQuery.val` instead of `jQuery.html`. For example `$("#" + rowid + "_Inflow").val("new Value")`, where `var rowid = $(e.target).closest("tr.jqgrow").attr("id");` – Oleg Nov 29 '15 at 16:35