i've added custom button on the footer of jqgrid for adding record. The code is as under:
$("#jqgUsers").navGrid('#jqgpUsers', { edit: false, add: false, del: false, search: false })
.navButtonAdd('#jqgpUsers', {
caption: "",
buttonicon: 开发者_如何学Python"ui-icon-plus",
onClickButton: function () {
alert("Adding Row");
},
position: "last"
});
How can I open jqGrid add form while click on that add button?
You should just call the editGridRow manually with "new" as the first parameter (see here the documentation)
$(this).jqGrid("editGridRow", "new");
or with any properties or events like for example
$(this).jqGrid("editGridRow", "new", {recreateForm: true, closeAfterAdd: true});
I'm adding an additional answer because I have a different scenario with a beforeShowForm event defined in my pager. In order to make sure the add row settings and events in my pager definition are used when the add row dialogue is opened with a custom button click I called
`$('#add_' + your_grid_name_here).click();`
Which will make sure your grid's pager settings are used. It's works the same as if the user pressed the '+' button in the pager.
精彩评论