2

Different texts for edit and add form for Save button are specified using bSubmit. If edit form is opened and closed, add form is opened and closed and edit form is opened again, edit form button caption becomes "Add row". How to fix this so that edit form save button text is "Save edits" always ?

I tried

bSubmit: function() { return "Save edits" },

put this prints function() ... in button.

grid.navGrid("#grid_toppager", { refreshstate: 'current' }, 
          { url: 'Edit',
                editData: { _dokdata: FormData },
                savekey: [true, 13],
                closeOnEscape: true,
                bSubmit: "Save edits",
                reloadAfterSubmit: false
            },

       { url: 'Add',
           bSubmit: "Add row",
           editData: { _dokdata: FormData },
           savekey: [true, 13],
           recreateForm: true,
           closeOnEscape: true,
           clearAfterAdd: true,
           addedrow: 'last',
           reloadAfterSubmit: false,

           afterSubmit: function (response) { return [true, '', response.responseText] }
             }
       } );
Andrus
  • 26,339
  • 60
  • 204
  • 378

1 Answers1

6

You should use just use recreateForm: true property:

myGrid.jqGrid('navGrid', '#pager',
    { add: true, edit: true, del: false, search: false },
    { bSubmit: "Submit Edit", recreateForm: true },  // Edit options
    { bSubmit: "Submit Add", recreateForm: true }    // Add options
);

See the demo.

If you would search for recreateForm you will find how many time I wrote recommendation of use it. I posted even the suggestion to make the recreateForm:true and recreateFilter:true as default settings, but received no response. I can only repeat use the settings as your default settings and you will have less problems. If you use custom editing controls you have to use the setting in the most implementations of the custom editing (see here).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thank you. Excellent. Maybe to create push request in github, I have noticed that Tony has committed them. closeAfterAdd: true decreases document detail entry speed, user should invoke add command to add every detail so I'm not using it. – Andrus Aug 08 '11 at 07:28