title: How to use free jqgrid properties to conditionally add actions buttons
body: <p>free jqgrid shows orders. Posted orders should have yellow background and only open action button.
  Unposted orders have white background, standard delete and custom post action button.</p>
  
  <p>colmodel for actions column:</p>
  
  <pre><code>{"hidden":false,"label":"Activity","name":"_actions","search":false,"width":94
  ,"sortable":false,"formatter":"actions","viewable":false,"formatoptions":{"editbutton":false,"onSuccess":function (jqXHR) { jqXHRFromOnSuccess=jqXHR;return true;}
  ,"delbutton":true,"delOptions":{"url":"http://localhost:52216/admin/Grid/Delete?_entity=DoklstlT","afterComplete":function (response, postdata, formid) { 
  summarefresh($grid);
  $grid[0].focus(); 
  }
  }}},
  </code></pre>
  
  <p>posted state is detemined by boolean Kinnitatud column :</p>
  
  <pre><code>{"label":null,"name":"Kinnitatud","index":"Kinnitatud","editoptions":{"value":"True:False","readonly":"readonly","disabled":"disabled"},"template":"booleanCheckboxFa","editable":true,"width":0,"classes":null,"hidden":true,"searchoptions":{"sopt":["eq","ne"],"value":":Free;true:Yes;false:No"},"dataEvents":[{"type":"focus","fn":function(e) {if(typeof e.target.ischanged=='undefined') {e.target.ischanged=false}}
  },"",{"type":"click","fn":function(e) {dataChanged(e.target)}
  },{"type":"blur","fn":function(e) {summarefresh()}
  }]}],
  </code></pre>
  
  <p>in other grid posted state is determined by Kinkuup column which is not filled for unposted documents:</p>
  
  <pre><code>{"template":DateTemplate
  ,"label":null,"name":"Kinkuup","index":"Kinkuup","editoptions":{"dataInit":null,"size":10,"readonly":"readonly","disabled":"disabled"},"searchoptions":{"dataInit":initDateSearch
  ,"size":10,"attr":{"size":10}},"width":0,"classes":null,"hidden":true,"dataEvents":[]}],
  </code></pre>
  
  <p>Both columns can hidden or visible in grid. depending on user preferences.</p>
  
  <p>Custom actions buttons are created in loadComplete for all rows:</p>
  
  <pre><code>       loadComplete: function() {
              var iCol = getColumnIndexByName($(this),'_actions');
              $(this).children("tbody").children("tr.jqgrow")
                 .children("td:nth-child("+(iCol+1)+")")
                 .each(function() {
  
                     $("&lt;div&gt;",
                       {
                           title: "Confirm (F2)",
                           mouseover: function() {
                               $(this).addClass('ui-state-hover');
                           },
                           mouseout: function() {
                               $(this).removeClass('ui-state-hover');
                           },
                           click: function(e) {
                               resetSelection();
                               idsOfSelectedRows = [$(e.target).closest("tr.jqgrow").attr("id")];
                               $("#grid").jqGrid('setSelection', $(e.target).closest("tr.jqgrow").attr("id"), false);
                               $('#grid_postbutton').click();
                           }
                       }
                  ) 
                   .addClass("ui-pg-div ui-inline-post")
                   .append('&lt;span class="fa ui-state-default fa-fw fa-lock"&gt;&lt;/span&gt;')
                   .prependTo($(this).children("div"));
  
  
                     $("&lt;div&gt;",
                         {
                             title: "Open (Enter)",
                             mouseover: function() {
                                 $(this).addClass('ui-state-hover');
                             },
                             mouseout: function() {
                                 $(this).removeClass('ui-state-hover');
                             },
                             click: function(e) {
                                 openDetail($(e.target).closest("tr.jqgrow").attr("id"));
                             }
                         }
                      )
                       .addClass("ui-pg-div ui-inline-open")
                       .append('&lt;span class="fa ui-state-default fa-folder-open-o"&gt;&lt;/span&gt;')
                       .prependTo($(this).children("div"));
  
                 }); 
  </code></pre>
  
  <p>After that buttons are conditionally removed using code from <a href="https://stackoverflow.com/questions/29343222/how-to-remove-action-buttons-from-posted-rows-in-free-jqgrid-using-fontawesome-c">How to remove action buttons from posted rows in free jqgrid using Fontawesome checkbox formatter</a> , row editing is conditionally disabled and background changed.</p>
  
  <pre><code>   disableRows('Kinkuup', false);
     disableRows('Kinnitatud', true);
  
  
   var disableRows = function (rowName, isBoolean) {
      var iCol = getColumnIndexByName($grid, rowName),
                cRows = $grid[0].rows.length,
                iRow,
                row,
                className,
                isPosted,
                mycell,
                mycelldata,
                cm = $grid.jqGrid('getGridParam', 'colModel'),
                iActionsCol = getColumnIndexByName($grid, '_actions'), l,
                isPostedStr;
      l = cm.length;
      for (iRow = 0; iRow &lt; cRows; iRow = iRow + 1) {
          row = $grid[0].rows[iRow];
          className = row.className;
          if ($(row).hasClass('jqgrow')) {
              isPostedStr = $.unformat.call($grid[0], row.cells[iCol],
            { rowId: row.id, colModel: cm[iCol] }, iCol);
              //if (cm[iCol].convertOnSave) {
              //    isPosted = cm[iCol].convertOnSave.call(this, {
              //        newValue: isPostedStr,
              //        cm: cm[iCol],
              //        oldValue: isPostedStr,
              //        id: row.id,
              //        //item: $grid.jqGrid("getLocalRow", row.id),
              //        iCol: iCol
              //    });
              //}
              isPosted = isPostedStr !== "False" &amp;&amp; isPostedStr.trim() !== "";
  
              if (isPosted) {
                  if ($.inArray('jqgrid-postedrow', className.split(' ')) === -1) {
                      // todo: how to disable actions buttons and form editing:
                      row.className = className + ' jqgrid-postedrow not-editable-row';
                      $(row.cells[iActionsCol]).attr('editable', '0');
                      $(row.cells[iActionsCol]).find("&gt;div&gt;div.ui-inline-del").hide();
                      $(row.cells[iActionsCol]).find("&gt;div&gt;div.ui-inline-post").hide();
                      $(row.cells[iActionsCol]).find("&gt;div&gt;div.ui-inline-edit").hide();
                  }
              }
          }
      }
  };
  </code></pre>
  
  <p>How to use free jqgrid actions options to simplify this code ?</p>
  
  <p>How to create uniform way to hide both standard edit and delete and user defined actions buttons? Hiding standard buttons still requires DOM modification even if custom button creating can conditionally disabled using callback. Maybe to define all actions buttons in same way.
  Maybe it can done using existing rowattr or cellattr callbacks or introducing new one.</p>
  
  <p>Currently row is et to read only in code below using</p>
  
  <pre><code>row.className = className + ' jqgrid-postedrow not-editable-row';
  $(row.cells[iActionsCol]).attr('editable', '0');
  </code></pre>
  
  <p>Is it reasonable to thant this so that diableRows can completely removed ?
  Maybe rowattr() can used instead of this.</p>