2013-10-10 1 views
2

jqgrid의 inlineNav 옵션을 사용하여 툴바에 '추가'옵션을 추가하고 있습니다. 또한 편집 및 삭제 작업 포맷터를 사용하고 있습니다. 새 행을 추가하면 새로 추가 된 행에는 편집 아이콘과 취소 아이콘이 표시되는 반면 저장 아이콘은 추가 옆에있는 도구 모음에 있습니다.jqgrid inlineNav add - 추가 된 행에 저장 아이콘 표시

편집 아이콘이있는 대신 새로 추가 된 행에 저장 및 취소 아이콘이 있음을 지정하는 방법이 있습니까?

답변

2

누구나 비슷한 질문이있는 경우.

나는 내 자신의 포맷터를 굴리기 시작했다. 행 인해 추가되는 저장 한 후 isSavedRow이 포맷터의 경우 사실로 전달되는

inlineNavAction = function(cellvalue, options, rowObject, isSavedRow){ 
     if(isSavedRow !== true){ 
      var rowid = options.rowId; 
      var ocl = "id='jSaveButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'save'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; 
      var str = "<div title='"+$.jgrid.edit.bSubmit+"' style='float:left;' class='ui-pg-div ui-inline-save' "+ocl+"><span class='ui-icon ui-icon-disk'></span></div>"; 
      ocl = "id='jCancelButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'cancel'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; 
      str += "<div title='"+$.jgrid.edit.bCancel+"' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-cancel' "+ocl+"><span class='ui-icon ui-icon-cancel'></span></div>"; 
      return "<div style='margin-left:8px;'>" + str + "</div>"; 

     }else{ 
      return $.fn.fmatter.actions(cellvalue, options, rowObject); 
     } 

    } 

다시 호출되고. 또한 rowId의 기본값은 0입니다. 기본 조작에 대해 false를 전달하십시오. 저장과 버전에 대한 GitHub의에서 사용할 수있는 소스로부터 취소에 대한 나는 마크 업을했다 4.5

사용법 :

formatter: function(cellvalue,options,rowObject) { 
    return inlineNavAction(cellvalue,options,rowObject, (options.rowId!='new_row')); 
} 

(options.rowId!='new_row') 

의 NEW_ROW는 기본 ROWID로 설정 한대로입니다 행이 추가되었습니다. new_row가 기본값입니다.

formatter: function (cellvalue, options, rowObject) { 
       if (cellvalue === undefined && options.rowId === "_empty") { 
        // remove edit and del buttons 
        options.colModel.formatoptions.editbutton = false; 
        options.colModel.formatoptions.delbutton = false; 
       } 
      return $.fn.fmatter.actions(cellvalue, options, rowObject); 
     }, 

다음 inlineNavaddParams에서 우리는이 :

0

변경 action 컬럼의 formatter

  addParams: { 
       position: "last", 
       rowID: '_empty', 
       useDefValues: true, 
       addRowParams: { 
       url: '....', 
       key: true, 
       restoreAfterError: false, 
       oneditfunc: function(rowId) { 
        // display the save and cancel buttons 
        $("#jSaveButton_" + rowId).show(); 
        $("#jCancelButton_" + rowId).show(); 
       }, 
     // ... the rest 
      }, 
관련 문제