📜  jqgrid navbuttonadd (1)

📅  最后修改于: 2023-12-03 15:02:09.228000             🧑  作者: Mango

jqGrid NavButton Add

jqGrid NavButton Add is a method in the popular jQuery plugin jqGrid. It allows developers to add custom buttons to the navigation toolbar of their grid. This feature is useful when you want to add custom actions to your grid but don't want to add them to the context menu.

Usage

To use the NavButton Add feature, you need to include the jqGrid library in your project. Here's an example of how to add a custom button to the navigation toolbar:

$("#myGrid").jqGrid('navButtonAdd', '#myPager', {
    caption: "My Custom Button", 
    buttonicon: "ui-icon-custom",
    onClickButton: function () {
        // code to handle button click
    },
    position: "last"
});

In this code, we are adding a button to the navigation toolbar of the grid with the ID "myGrid". The new button has the caption "My Custom Button" and a custom icon defined by the CSS class "ui-icon-custom". When the button is clicked, the function defined in the onClickButton parameter will be called.

Parameters

The jqGrid NavButton Add method takes several parameters:

  • caption: The text that will appear on the button.
  • buttonicon: The icon that will appear on the button. This should be the name of a CSS class that defines the icon.
  • onClickButton: The function that will be called when the button is clicked.
  • position: The position where the button should be added in the navigation toolbar. Valid values are "first", "last", "prev" and "next".
Conclusion

jqGrid NavButton Add is a powerful feature that allows developers to add custom buttons to their grid's navigation toolbar. With this feature, developers can enhance the functionality of their grids and provide a better user experience for their users.