Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
718 views
in Technique[技术] by (71.8m points)

how to add different texts to save button in edit and add forms in jqgrid

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] }
             }
       } );
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...