0

I have a jqGrid with four columns and in which i get the rows from the database. Now i want some thing like this. On row selection the cell value of row has to be changed.

i.e.

 SNo       SName      Update     Roll No
  1        Steve      Rename      1001
  2         Jack      Rename      1002

I want to update the SName when the user selects Rename from jqGrid row for example if the user selectes rename from first row then first row should be like the following

i.e.

SNo       SName        Update         Roll No
 1        Steve     Update/Cancel      1001
 2        Jack         Rename          1002

Can any one suggest me how to obtain the same

Oleg
  • 220,925
  • 34
  • 403
  • 798
hkv
  • 163
  • 1
  • 6
  • 15
  • 1
    Please verify that the edited text (reformated) corresponds to what you want to ask. – Oleg Dec 01 '10 at 11:38
  • 1
    You should specify which kind of row editing you use (form editing, inline editing, cell editing or some form of custon editing). Do you use some custom formatting? – Oleg Dec 01 '10 at 11:41
  • This is that format. I want to use inline editing for the above. – hkv Dec 01 '10 at 13:07

1 Answers1

0

It seems to me that you try to make things more complex as it is. Why do you not use the standard behavior of the jqGrid "inline editing"?

If user double-click (or click depend on your requirements) on the row the "editable" columns of the row can be modified (see old answer for more information). If the user end the row editing with pressing of "Enter" key the changed will be saved. If the user press "Esc" key or select another row the changes will be discarded. So the standard inline editing supports rename/update/cancel without additional "update" column.

If you want have a buttons in an additional column you can use formatter:"actions" or use "custom editing" technique which you can see on the jqGrid demo if you select "Row Editing" / "Custom Edit".

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I have checked and its working fine but what if i need to pass the same to the server side so that it also affects the DB. When i press enter then it changes but for that session alone.Can u please suggest me how to fetch that edited value of the row so that i will pass the same to the server and do my required updation – hkv Dec 02 '10 at 07:30
  • I mean, after i press enter i need to pass that edited value to server so that in DB it also gets the value for ehich i do the following ondblClickRow: function(id, ri, ci) { jQuery("#tblList").jqGrid("editRow",id,true); fnRowVal(rowid);}, function fnRowVal(ale){var rowval = $("#"+ale); $('#dvFecthData').html(rowval.html()); var SelectedValue=$('#dvFecthData.editable').val();$("#tblList" + strTabs).jqGrid('setGridParam',{url:"Default.aspx?q=1&ToUpdateList="+SelectedValue}).trigger("reloadGrid");} – hkv Dec 02 '10 at 08:03
  • 1
    @hkv: If `editurl` parameter defined, jqGrid post the modified data to the url as a part of the work which do `editRow` method. You should only implement the corresponding Web-Method on the server side. See http://stackoverflow.com/questions/3917102/jqgrid-add-row-and-send-data-to-webservice-for-insert/3918615#3918615 as an example. – Oleg Dec 02 '10 at 08:18
  • Thanks for your continuous support and i have got the output by the example shown. Thanks a lot Oleg. – hkv Dec 03 '10 at 05:18