1

I'm sure my questions have been addressed somewhere, but I've researched for a while now and can't seem to find the answers I'm looking for.

  • When using the inlineNav feature, is there a "delete" option? I haven't found any, so in order to use it, I have to create the grid using both the navGrid and inlineNav features, like this:
  $("#attributeEditList").jqGrid( { 
            datatype: "local",
            height: 150,
            colNames: ['rowid', 'Vendor', 'Category', 'Key', 'Value', 'Flags', 'Status'], 
            colModel: [
                        {name: 'rowid', index: 'rowid', hidden: true, key: true},
                        {name: 'vendorCode', index: 'vendorCode', hidden: true},
                        {name: 'category', index: 'category', width: 120, editable: true, editrules:{required: true} }, 
                        {name: 'key', index: 'key', width: 120, editable: true, editrules:{required: true} }, 
                        {name: 'value', index: 'value', width: 200, editable: true, editrules:{required: true} }, 
                        {name: 'flags', index: 'flags', width: 80, editable: true, editrules:{required: true, integer: true} }, 
                        {name: 'status', index: 'status', hidden: true }
                      ], 
            sortname: "category", 
            viewrecords: true,
            caption: "Attributes",
            rowNum: 20000,
            pager: '#attributeEditPager',
            editurl: "vendor/ajax/dummy.do",
            data: vendor.attributes,
            jsonReader : { repeatitems: false }
          });
          $("#attributeEditList").jqGrid( "navGrid", '#attributeEditPager', {
              edit: false, 
              add: false, 
              del: true,
              search: false,
              refresh: false,
              delfunc: deleteAttribute
            }
          );  
          $("#attributeEditList").jqGrid( "inlineNav", '#attributeEditPager' );  
  • Is there any way to make the edits in the grid strictly client-side? I want my user to be able to make several edits (add/edit/delete) then post all of the changes in the grid, plus some other form changes outside of the grid, back to the server atomically. As far as I can tell, the editurl parameter is required, and must actually be a valid url, for editing to work.
  • Last, and I think this is the biggest issue I'm having, is when using the inlineNav feature. First, I click the "Add (+)" button to add a row, add the data, then click the "save" button. Then, if I click the "Add" button again, a new row is added, but the "Add" and "Edit" buttons remain active, while the "Save" and "Cancel" buttons are still disabled.

If you have any advice on these issues, please let me know.

pconrey
  • 5,805
  • 7
  • 29
  • 38

1 Answers1

1

Look at the demo from the old answer where I demonstrate how one can implement local form editing in jqGrid. You first question was about the "Delete" added by navGrid. So you can use the trick with setting processing: true which I suggested to make "Delete" button working locally. You should additionally use editurl: 'clientArray'. I posted my suggestion to trirand about one year ago (see here), but the local form editing is still not the part of jqGrid.

You are right that there are many situations in which inlineNav work buggy and if the user clicks on the buttons in a little other order one have wrong activated or wrong deactivated buttons. You have to activate/deactivate the buttons manually using $("#attributeEditList_ilsave").removeClass('ui-state-disabled'); or $("#attributeEditList_ilsave").addClass('ui-state-disabled');. The ids of the buttons will be constructed from the gridid and the postfix "_iladd", "_iledit", "_ilsave", "_ilcancel". I recommend you include such code in the onSelectRow or beforeSelectRow till the bugs will be not fixed in the main code of jqGrid.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Concerning the last question, is there an event fired when editing begins on a row? Otherwise, how will I know whether or not the row is in edit mode or not? – pconrey Mar 15 '12 at 23:01
  • Also, for the record, here is the first part of the error stack that occurs (from developer tools in Chrome) when I click on the "Add" button the second time:
    Uncaught TypeError: Cannot read property 'name' of undefined
    $.jgrid.extend.editRow.each.svr.id
    e.extend.each
    e.fn.e.each
    $.jgrid.extend.editRow
    e.extend.each
    e.fn.e.each
    $.jgrid.extend.editRow $.fn.jqGrid ...
    – pconrey Mar 15 '12 at 23:01
  • @pconrey: You can use [$.jgrid.inlineEdit](https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.inlinedit.js#L35-46) to set any from the callback functions like `oneditfunc` wich will be called at the beginning of inline editing. You can also use `editParams.oneditfunc` and `addParams.addRowParams.oneditfunc` inside of option of the [inlineNav](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#inlinenav). You can try to use the current version of jqGrid from [github](https://github.com/tonytomov/jqGrid/). It contains some important bug fixes. – Oleg Mar 15 '12 at 23:10
  • I'm using 4.3.1. I don't see anything newer on github. I've figured out how to activate and deactivate the buttons in the inlineNav params, but it appears that once a row is saved (after being added) that the grid ignores the callback functions passed into the inlineNav setup. As it sits right now, the inlineNav is just too buggy to use. Even the [inlineNav demo](http://trirand.com/blog/jqgrid/jqgrid.html) exhibits the incorrect behavior. – pconrey Mar 19 '12 at 20:03