Table of Contents

Navigator

The Navigator is a user interface feature that allows easy accessibility to record actions such as Find or Edit. The user can activate a grid action by pressing the appropriate icon button in the Navigation layer.

Developers can create custom actions, or they can use any of the six predefined actions that come with jqGrid. jqGrid provides icon button graphics for the predefined actions.

The full set of predefined actions are:

1) Add New Row, 2) Edit Selected Row, 3) View Selected Row, 4) Delete Selected Row, 5) Find Records, and 6) Reload Grid

The image below shows these six buttons in the bottom-left.

The Navigation layer doesn't have to be located on the bottom: it can be positioned inside the grid window. Also, the Navigation layer itself is optional and can be removed.
* You can also add your own custom buttons with custom actions to the Navigation layer.
  • You can also change the text that appears when a user hovers over a button (see below: that text is found in the language file)

* Navigator buttons can be positioned on the left, middle, or right side.

How to Use:

The Navigator is a jqGrid method. It's activated and configured by extending your main grid function, as shown in the code examples below. The full list of all possible configurable parameters is listed in the table below.

The built-in Navigator should be applied to the pager element. In other words, the pager element should be defined. The built-in Navigator actions correspond to the form editing actions. For more information and details refer to Form Editing.

Definition

In order to use the Navigator the Form Edit module , Common module and optionally the search and Modal modules, should be checked when you download the grid. Refer to Download section.

HTML definition

...
<body>
...
   <table id="list"></table> 
   <div id="gridpager"></div> 
...
</body>

JavaScript code

<script>
...
jQuery("#grid_id").jqGrid({
...
   pager : '#gridpager',
...
});
jQuery("#grid_id").navGrid('#gridpager',{parameters},prmEdit, prmAdd, prmDel, prmSearch, prmView);
...
</script>

Using the new API

<script>
...
jQuery("#grid_id").jqGrid({
...
   pager : '#gridpager',
...
});
jQuery("#grid_id").jqGrid('navGrid','#gridpager',{parameters},prmEdit, prmAdd, prmDel, prmSearch, prmView);
...
</script>

or in chained mode

<script>
...
jQuery("#grid_id").jqGrid({
...
   pager : '#gridpager',
...
}).navGrid('#gridpager',{parameters}, prmEdit, prmAdd, prmDel, prmSearch, prmView);
...
</script>

Where:

Additionally to every particular module defined with prmEdit, prmAdd, prmDel, prmSearch, prmView a id parameter can be passed in order to identify the id of the button in the Navigator. If this id is not defined we use the combination of a prefix and the grid id. See below.

If the id of the button is not set we use the following rule:
For the add button we use “add_” + the id of the grid
For the edit button we use “edit_” + the id of the grid
For the delete button we use “del_” + the id of the grid
For the view button we use “view_” + the id of the grid
For the search button we use “search_” + the id of the grid
For the refresh button we use “refresh_” + the id of the grid

The code below defines a edit button with id myedit.

<script>
...
jQuery("#grid_id").jqGrid({
...
   pager : '#gridpager',
...
}).navGrid('#gridpager',{}, {id:'myedit'});
...
</script>
If a class ui-state-disabled is added to some of these buttons we disable not only the button, but the click action too

Parameters

When we use the Navigator the following options are included from the language file.

If you want to change the text that appears when a user hovers over a button, simply replace the text in the title string in the bottom part of the code below. For example: hover text for the view button is supplied by viewtitle: “View selected row”
$.jgrid = {
...
   search : {
     caption: "Search...",
     Find: "Find",
     Reset: "Reset",
     odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
     groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
     matchText: " match",
     rulesText: " rules"
   },
   edit : {
     addCaption: "Add Record",
     editCaption: "Edit Record",
     bSubmit: "Submit",
     bCancel: "Cancel",
     bClose: "Close",
     saveData: "Data has been changed! Save changes?",
     bYes : "Yes",
     bNo : "No",
     bExit : "Cancel",
  },
  view : {
    caption: "View Record",
    bClose: "Close"
  },
  del : {
    caption: "Delete",
    msg: "Delete selected record(s)?",
    bSubmit: "Delete",
    bCancel: "Cancel"
  },
  nav : {
    edittext: "",
    edittitle: "Edit selected row",
    addtext:"",
    addtitle: "Add new row",
    deltext: "",
    deltitle: "Delete selected row",
    searchtext: "",
    searchtitle: "Find records",
    refreshtext: "",
    refreshtitle: "Reload Grid",
    alertcap: "Warning",
    alerttext: "Please, select row",
    viewtext: "",
    viewtitle: "View selected row"
  },
...

The options $.jgrid.edit, $.jgrid.add, $.jgrid.del and $.jgrid.search are included to tier modules if enabled.

The full list of the parameters is as follow:

PropertyTypeDescriptionDefault1)
addboolean Enables or disables the add action in the Navigator. When the button is clicked a editGridRow with parameter new method is executedtrue
addiconstringSet a icon to be displayed if the add action is enabled. Note that currently only icons from UI theme images can be addedui-icon-plus
addtextstring The text than can be set in the add buttonempty
addtitlestringThe title that appear when we mouse over to the add button (if enabled) Add new row
alertcapstring The header of the message that appear when we try to edit,delete or view a row without to select it Warning
alerttextstring The message text that appear when we try to edit,delete or view a row without to select it Please, select row
cloneToTopboolean Clones all the actions from the bottom pager to the top pager if defined. Note that the navGrid can be applied to the top pager only. The id of the top pager is a combination of grid id and “_toppager”false
closeOnEscapebooleanDetermine if the alert dialog can be closed if the user pres ESC keytrue
delboolean Enables or disables the delete action in the Navigator. When the button is clicked a delGridRow method is executed.true
deliconstringSet a icon to be displayed if the delete action is enabled. Note that currently only icons from UI theme images can be usedui-icon-trash
deltextstring The text than can be set in the delete buttonempty
deltitlestringThe title that appear when we mouse over to the delete button (if enabled) Delete selected row
editboolean Enables or disables the edit action in the Navigator. When the button is clicked a editGridRow method is executed with parameter the - current selected rowtrue
editiconstringSet a icon to be displayed if the edit action is enabled. Note that currently only icons from UI theme images can be usedui-icon-pencil
edittextstring The text than can be set in the edit buttonempty
edittitlestringThe title that appear when we mouse over to the edit button (if enabled) Edit selected row
positionstringDetermines the position of the Navigator buttons in the pager. Can be left, center and right. left
refreshbooleanEnables or disables the refresh button in the pager. When the button is clicked a trigger(“reloadGrid”) is executed and the search parameters are clearedtrue
refreshiconstringSet a icon to be displayed if the refresh action is enabled. Note that currently only icons from UI theme images can be usedui-icon-refresh
refreshtextstring The text than can be set in the refresh buttonempty
refreshtitlestringThe title that appear when we mouse over to the refresh button (if enabled)Reload Grid
refreshstatestringDetermines how the grid should be reloaded
- firstpage - the grid reload the data from the first page.
- current - the reloading should save the current page and current selection
firstpage
afterRefreshfunctionIf defined this event fire after the refresh button is clickednull
beforeRefreshfunctionIf defined this event fire before the refresh button is clickednull
searchbooleanEnables or disables the search button in the pager.When the button is clicked a searchGrid method is executedtrue
searchiconstringSet a icon to be displayed if the search action is enabled. Note that currently only icons from UI theme images can be usedui-icon-search
searchtextstring The text than can be set in the search buttonempty
searchtitlestringThe title that appear when we mouse over to the search button (if enabled)Find records
viewbooleanEnables or disables the view button in the pager. When the button is clicked a viewGridRow method is executedfalse
viewiconstringSet a icon to be displayed if the search action is enabled. Note that currently only icons from UI theme images can be usedui-icon-document
viewtextstring The text that can be set in the view buttonempty
viewtitlestringThe title that appear when we mouse over to the view button (if enabled)View selected row
addfuncfunctionIf defined replaces the build in add function. No parameters are passed to this function null
editfuncfunctionIf defined replaces the build in edit function. Parameter passed to this function is the id of the edited row null
delfuncfunctionIf defined replaces the build in del function. Parameter passed to this function is the id of the edited row null

For the particular options regarding the editing methods refer to Form Editing

Example:

<script>
...
jQuery("#grid_id").jqGrid({
...
   pager : '#gridpager',
...
}).navGrid('#gridpager',{view:true, del:false}, 
{}, // use default settings for edit
{}, // use default settings for add
{},  // delete instead that del:false we need this
{multipleSearch : true}, // enable the advanced searching
{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key*/
);
...
</script>

The above example enables the grid view mode form enabling closing of the modal dialog with ESC key and sets advanced searching. It also disables the delete action.

1)
English variant