tags:

views:

44

answers:

1

I have a grid with some hidden datas and also I have some custom links on each row (eg: "publish/unpublish", "edit", "delete"). When I click on the link "publish/unpublish" on each row, the row data should get updated automatically and the values should get posted to the server. After successful submit the grid row should get refreshed automatically with new values. How can I achieve this functionality with the above scenario.

NOTE: When I click on the link, the row should never turn to editable mode.

+1  A: 

You don't wrote which editing mode you use. It seems you use cell editing. If you use cell editing mode you can use saveCell instead (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing#methods). If you use line editing mode you can use saveRow to save the data (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow).

To send additional hidden column data (if you use line editing mode) to the server you can use following additional column option for the hidden columns:

editable: true, editrules: { edithidden: false }

See http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options and http://stackoverflow.com/questions/3176157/sending-additional-parameters-to-editurl-on-jqgrid/3177531#3177531.

Any cell can have additional class "not-editable-cell" to deny switching of editing mode in case of cell editing mode. You can use classes column option to add this class to the link column.

Oleg
thanks for your reply Oleg. I already went through the above scenarios but my question is, when I click on the link "publish/unpublish" the row or cell should never turn into editable mode. It should simply do some backend operation and refresh the particular row grid. Eg:Suppose I have a grid which holds the user details and I want to deactivate a user from the list. At that time, I will click on "publish/unpublish" link, the row or cell should never turn to editable mode (i.e. Input elements) instead simply it should send some data to the server where it will update the user status.
karuh24
Karuh, you don't write which editing mode you use. Is it cell editing mode? Then setting on the class "not-editable-cell" to the column with the link "publish/unpublish" will never turn into cell editable mode. You can also use `beforeSelectRow` event and return `false` if you don't need select the row. Probably http://www.trirand.com/blog/?page_id=393/help/tabletogrid-selcol-with-input-fields/ will help you. If you stay having the problem, please post a code example to make all more clear.
Oleg
Oleg, I solved the above issue in a different manner, When the link is clicked, I will call an js function using the "formatter" option. In that function, I will change the cell values using "setRowData" method (i.e. clientside change). This function will return true if the row are updated properly. If it is true, I will trigger an ajax action where it will do some operation at the backend. So that, I can easily manage the row values dynamically by clicking on the link (i.e. without changing the row in the editable mode).
karuh24
OK! It's fine if the problem solved. By the way the function `saveCell` save the data (like `setRowData`) including decoding of data depends on the cell type (checkbox, select etc) and make the ajax call if cellsubmit == 'remote' and save data locally if cellsubmit == 'clientArray'. In general you can do a lot of things yourself, but I recommend you to invest a little time to study possibilities of jqGrid. It will simplify development. The best way is looking into source code of jqGrid, for example, grid.celledit.js which a part of standard download from http://www.trirand.com/blog/?page_id=6.
Oleg