1

When I open form to edit values:

  1. It doesn't change form values when I navigate with <> buttons

  2. It opens New form with same values as first edited row, and when I click "Submit", it overwrites that row instead of creating a new item

  3. When I click to edit another row, it always shows the form values for the first edited row – i.e. if I click New first and then edit row, it shows empty form.

So, in short, the first time form opens, the values are "stuck" whatever row I open later.

What can cause this? I remember it used to work OK some time ago.

UPDATE:

No with recreateForm I don't have this issue (I use it as temporary workaround).

Hm, I can reproduce this on jqGrid example, but not on Live Manipulation - on New in Version 3.7, Add/edit/delete on local data:

  1. Click any row and edit it (open form)
  2. Close form
  3. Select any other row and click edit - form shows incorrect values (from the row that was opened first)
  4. Click Add new row button in toolbar - form shows same values - which is very convenient, usually new rows are "almost" same - if only it would add new row, not update the existing one!

Of course in live demo Submit doesn't do that (it doesn't seem to work at all) but except for this symptoms are same.

Also <> buttons do not change data in form, though they change selected row - but from what I remember previously it used to update form values also to match selected row.

mailazs
  • 341
  • 6
  • 22
queen3
  • 15,333
  • 8
  • 64
  • 119
  • Could you post an example or a URL of example which can be used to reproduce the problem? Do you have the same results if you use `recreateForm:true` parameter for the edit and add dialogs? I recommend you always use `recreateForm:true`. – Oleg Nov 09 '10 at 18:43
  • Could you reproduce your results of the demo http://trirand.com/blog/jqgrid/jqgrid.html is you choose "Live Data Manipulation" on the tree and then "Navigator"? Moreover you should probably rewrite in other words your question. For example "form to edit values" should not "create a new item" (see 2). Do you speak about "Add new row" or "Edit selected row"? Buttons "<" and ">" to navigate to the next or previous row and not to change the data. It work per default as "Esc" (discard changes) and Edit next/previous row. Could you explain your scenario more exactly? – Oleg Nov 09 '10 at 19:18

1 Answers1

4

Probably you should post the description of your bug with "New in Version 3.7", "Add/edit/delete" as a bug in the in trirand forum.

The problem is that the bug exist in very special environment/data/settings. For example I tested my old local edit example modified to jqGrid 3.8.1 or in 3.7.2 and can not reproduce the problem which you describes. So you can use my examples as a template could it helps you.

Moreover in all examples which I use for real projects I use always parameter recreateForm:true. If you don't use it jqGrid not create a form, but try to use an existing with other data. It works in a lot of cases wrong. For example if you use any dataInit functions they will be called only once during creating of the form, which can make very strange affects. If you use edittype: 'custom' the usage of recreateForm:true is really mandatory (see this). So I recommended many times all people to use

jQuery.extend(jQuery.jgrid.edit, {recreateForm: true});

to set recreateForm: true as your default settings. You could save many hours or days of debugging of some strange effects in your edit/add dialogs.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • OK, thanks for your response. As for recreateForm, I use dataUrl selects and re-loading them with each form doesn't look good; so I'd prefer not to use recreateForm or use it but cache selects; maybe I can do this with custom select loaders. – queen3 Nov 09 '10 at 21:44
  • 1
    @queen3: The usage of `dataUrl` don't mean loading of the data will be many time. If you set in the server response the in the HTTP header `Cache-Control: max-age=60` for example, then all ajax calls on the client side will not send any `dataUrl` requests to the server during 60 sec. See http://stackoverflow.com/questions/3885658/jqgrid-data-stored-in-browser-cache/3885956#3885956 for a little more information. – Oleg Nov 09 '10 at 22:06
  • 1
    @queen3: One more time to be clear. 1) I recommend you to post a bug to jqGrid developers 2) I recommend you **always** use `recreateForm: true` which save much of your time. I personally spend 2 days of debugging before I decide to do this in all my projects. All other optimization problems can be solved in other ways if you really will see any performance problems. But the usage of clear and a little slowly code is better as to use a buggy code and a mix of add/edit dialog settings. It is my personal opinion and my personal recommendation. You should choose the best way for you. – Oleg Nov 09 '10 at 22:12
  • OK. You _really_ sound like someone who has a lot of experience with this and was not satisfied at all - that's exactly how I would talk explaining why someone shouldn't use Crystal Reports, for example ;-) So I will take your advice. – queen3 Nov 10 '10 at 08:31
  • @Oleg - thank you for the recommendation to use `recreateForm:true` in all projects. I spent about 4 hours debugging my add/edit `navGrid` buttons and forms trying to figure out why a `` element with the `setColProp` method. Anyways, I appreciate very much all of your helpful `jqGrid` info, and especially this `recreateForm` tidbit! – kjones Oct 24 '12 at 18:14
  • 1
    @kjones: You are welcome! I repeat the recommendation to use `recreateForm: true` in many my answers. I spent myself many hours (I think it was even more as 4) for the same problem. I posted feature request to Tony (trirand) to change the defaults, but Tony have another opinion on the subject. Best wishes for you! – Oleg Oct 24 '12 at 19:34