0

I have 2 grids. in both of them i use loadonce:true . In the first grid i have a cell with an onblur event which opens a dialog with the second grid. after i edit the second grid i want to save as xml it's content and ascribe it to the row of the first grid (the row witch opened the dialog). In the end i want to generate an xml from the first grid that will include the xml I generated before in the second grid.

so what is the best way to implement this?

Thank's In Advance.

user590586
  • 2,960
  • 16
  • 63
  • 96
  • What do you mean under "hidden cell"? There are only hidden columns and no "hidden cells" in jqGrid. Do you mean setting of cell contain for the hidden column? – Oleg Feb 08 '11 at 11:34
  • @Oleg: sorry , i ment a hidden column. – user590586 Feb 08 '11 at 11:48
  • @Oleg: i updated my question with the xml string i want. – user590586 Feb 08 '11 at 11:53
  • If you use `loadonce:true`, that means that you have all data saved on the server. Why you need in the case any local XML data? `loadonce:true` will be typically used to show the data where you have problems with the implementation of server side paging or sorting. If you want allow **to modify** the data then the usage of `loadonce:true` makes the task many time complexer. The usage of local editing makes almost impossible tracing of parallel modifications of the same data from different user. So you will be probably unable to implement concurrency in your scenario. – Oleg Feb 08 '11 at 12:54
  • Because you rewrite the text of your question instead of appending it my old answer is absolutely wrong for your new question and I have to delete it. – Oleg Feb 08 '11 at 12:55

1 Answers1

0

Depend on how exactly you implement the scenario which you describe you could has any data in the internal data parameter of jqGrid existing always if one use local datatype or loadonce:true in your case.

Direct accessing to the data parameter per jQuery("#grid_id").getGridParam('data') get your reference to the data array. The data array contain all data of the grid (not only the current displayed page) and the data are not yet placed in the <td> element. So the data are unmodified and could contain for example any XML fragments.

UPDATED: To make you easier to understand what I mean I made the small demo. If you double-click on a row you will see the XML data associated with the row.

The "note" column can be hidden. Because all hidden columns exist in grid as HTML markup I made it visible. You can see the difference what can be saved as grid internal data and what can be displayed (also as hidden data).

UPDATED 2: You can consider to use autoencode:true option in your grids.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • @user590586: I appended demo to clear better how one can work with the 'data' parameter. – Oleg Feb 08 '11 at 13:54
  • @Oleg: really appritiate your help.. in your example can i modify the "note" column? and if so how ? – user590586 Feb 08 '11 at 15:13
  • @user590586: After you get **the reference to the 'data'** with `var data = $("#list").jqGrid('getGridParam','data');` you can modify any data directly. The modifications will be displayed an the next refreshing of grid like go to the next page, sorting and so on. Because you want probably modify the hidden row, then the time of refreshing is not important for you. – Oleg Feb 08 '11 at 15:58
  • @user590586: On http://www.ok-soft-gmbh.com/jqGrid/ChangeXmlDataInGrid.htm you can see how one can modify the data of selected row. If you double-click on the row after the resetting of `data` you will see the data started with "test0test2". If you go to the next page and back the displayed data will be also updated. – Oleg Feb 08 '11 at 17:00
  • 2
    @user590586: You can consider to use `autoencode:true` option in your grids. – Oleg Feb 09 '11 at 14:06
  • @Oleg: I just saw now , that after I added the "autoencode:true" to my grid - I have a problem with a button I create inside my grid: In my onselect row I'm adding a button: var button_input = ""; mygrid.jqGrid('setRowData' , id , { button: button_input } ); - the problem is that I see the html instead of the button itself.. how can I show a button? – user590586 May 18 '11 at 09:22
  • @user590586: There are many way how one can solve your problem. In general if you need to add HTML hragment to a column you should implement this as a [custom formatter](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter). The binding to events you can use as in your current code or use alternatives described [here](http://stackoverflow.com/questions/5303471/browser-memory-usage-comparison-inline-onclick-vs-using-jquery-bind/5305904#5305904) or [here](http://stackoverflow.com/questions/5010761/linking-from-a-column-value-in-jqgrid-to-a-new-page-using-get/5017528#5017528). – Oleg May 18 '11 at 10:04
  • @Oleg: I updated a previys question of mine - regarding this issue -[http://stackoverflow.com/questions/5169317/jqgrid-input-type-button-inside-cell-show-only-on-edit-mode] , I will really appritiate your help, thank's again. – user590586 May 19 '11 at 11:27