enable_edit() *

* Please note this feature is only available in paid versions. CELL edit is only available in the commercial licenses

  • Parameters:
    • $edit_mode: FORM, INLINE, or CELL. The default is FORM.
    • $operations: specify allowed datagrid edit operations. By default, all edit operations are allowed.
      • C = Create
      • R = Review
      • U = Update
      • D = Delete
    • $edit_file: Optional. Use a custom edit file other than the default “edit.php”. Do not set this parameter unless you ABSOLUTELY know what you are doing!
  • Description:
    • When Form edit mode is used, additional icons appear in the data grid footer used for editing. When set to inline mode, the cells in the selected row become editable when the row is clicked. Only a single row can be edited for either mode.
  • Remark:
    • Multiple records can be deleted when multiple select is enabled. See set_multiselect() for more information on this method.
    • For inline edit, the user must press Enter key to save changes
    • In FORM edit mode,  double click triggers the popup edit window to display. In INLINE edit it is a single click to edit, similar to how Excel works. This is a design decision.
    • When edit mode set to ‘CELL’, the datagrid will behave like an Excel spreadsheet. It is advisable to also enable keyboard navigation with enable_kb_nav().
  • Example:
1
$dg -> enable_edit('FORM', 'CRU'); // Everything is allowed but delete

It’s also possible to load a custom form in an iframe in a modal window with your own custom CRUD scripts. 

Quick Tip: Keep the edit form open after submit

To keep form open after submit, add the following javascript to override ‘closeAfterEdit’ value before </body>. Double click to edit a row, and form will remain open after edit.

Replace “orders” with your table name.

1
2
3
4
5
6
7
8
9
10
11
12
jQuery(document).ready(function($){
    var grid = $('#orders')[0];
    $(grid).jqGrid('setGridParam',{
            ondblClickRow: function(rowid) {
                $(this).jqGrid('editGridRow', rowid,
                    {   recreateForm:true,
                        closeAfterEdit:false,
                        closeOnEscape:true,
                        reloadAfterSubmit:false})
            }
        });
});