jqgrid recreateform width setting, only working for edit, not for add

后端 未结 1 561
别那么骄傲
别那么骄傲 2020-12-04 04:15

Have looked on the jqgrid wiki but cant find what i need.

i have recreateform set to true and setting the width, works fine for edit, but when i try to add a new rec

相关标签:
1条回答
  • 2020-12-04 04:38

    You misunderstand the meaning of recreateForm. I try to explain why it is needed.

    The method navGrid has up to 7 parameters. You use only prmEdit but not set the prmAdd parameter. That is your main problem. The default implementation of "Add" and "Edit" dialog is so that one created dialog will be not closed, and only hide instead. Moreover, one dialog will be shared (!!!) as "Add" and "Edit" dialog. If recreateForm is used that the previously created (and now hidden) dialog will be destroyed and the the new one will be created.

    In your case you defined only "Edit" dialog parameters as {closeOnEscape:true, recreateForm: true, width:600}. So if the user opens the "Add" dialog after the "Edit" dialog the previously hidden "Edit" dialog will be used as "Add" dialog. The title of the dialog will be changed of course.

    So you can for example use

    jQuery("#rowed2").jqGrid('navGrid',"#prowed2",
        {edit:true,add:true,del:true,search:true,refresh:true},// navGrid options
        {closeOnEscape:true, recreateForm: true, width:600},   // Edit options
        {closeOnEscape:true, recreateForm: true, width:500}    // Add options
    );
    

    or redefine the grid defaults which are common for both Edit and Add dialog. For example

    jQuery.extend(jQuery.jgrid.edit, {
        closeAfterAdd: true,
        closeAfterEdit: true,
        jqModal: false,
        recreateForm: true,
        savekey: [true,13]
    });
    
    0 讨论(0)
提交回复
热议问题