开发者

JQGrid Default button for adding

I'm new to JQgrid and can't figure out how to add a default button to the Add part of the grid.

So there is a grid with rows that have the columns: "Date, name and dose" for a medications grid. When they press the add medication button at the bottom it opens the add medication dialog with three textfields fo开发者_C百科r them to add this information. All I want to do is make it so that when they press "Enter" on this dialog it adds the medication. So that the don't have to press the add button in the dialog.

I don't even know where to put this in the JQGrid code, which is very big so I don't know which code to post, if anyone tells me sort of where I need to post it I can post code.

Thanks


Parameter savekey:[true,13] of Add/Edit forms will solve your problem.

For example,

$("#list").jqGrid('navGrid','#pager',{/*navGrid options*/},
                  {savekey:[true,13]},  // edit options
                  {savekey:[true,13]}); // add options

Because you probably want to have the settings in all the grids which you use you can prefer to change the default option of jqGrid for Add/Edit dialog on one place:

jQuery.extend(jQuery.jgrid.edit, {
    recreateForm:true,
    jqModal:false,
    reloadAfterSubmit:false,
    savekey: [true,13],
    closeOnEscape:true,
    closeAfterAdd:true,
    ...
});


I figured it out. It is an option that should go with the rest of your add dialog options.

bSubmit: "Add",
savekey: [true,13],
url: '<%=urlAddMedication%>',

The one in the middle is the solution, the other lines given for context.

savekey is the option for button to save, it needs an array of length 2. The first element is boolean depending on whether it should save or not. The second is the keycode of the button in question. (13 is the code for the enter key)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜