2012-09-13 1 views
2

잘 작동하는 jqgrid가 있습니다. 그러나 필자가 추가 한 행을 선택하여 삽입 행에 배치하려고합니다. 내가 삽입 된 행을 제대로 정렬하고 jqgrid 내부에 배치하고 싶습니다.jqgrid에서 추가 한 후 삽입 된 행을 선택하고 위치를 지정하는 방법은 무엇입니까?

지금까지는 삽입 된 행만 선택할 수 있었지만 그리드에서 올바르게 정렬되지 않았습니다. 삽입 된 행은 현재있는 페이지의 상단에 표시됩니다.

다음은 jqgrid에 새 행을 삽입하는 create 함수를 사용하는 코드 예제입니다.

$(document).ready(function() { 
     $('#jqgProducts').jqGrid({ 
      //url from wich data should be requested 
      url: '@Url.Action("DynamicGridData")', 


      //type of data 
      datatype: 'json', 
      mytype: 'POST', 
      //url access method type 
      //jsonReader:{repeatitems : false, id: "cSfPT"}, 
      //columns names 
      colNames: ['Šifra pošte', 'Naziv pošte', 'Napomena'], 
      //columns model 
      colModel: [ 
         { name: 'cSfPT', index: 'cSfPT', align: 'left', width: '100px', key: true, editable: true, search: true 

         }, 

         { name: 'cNzPt', index: 'cNzPt', align: 'left', width: '200px', editable: true, edittype: 'text', 
          }, 

         { name: 'cNapomena', index: 'cNapomena', align: 'left', width: '400px', 

         editrules: { required: false} } 
         ], 
      //pager for grid 
      pager: '#jqgpProducts', 
      //number of rows per page 
      rowNum: 10, 
      //initial sorting column 
      sortname: 'cSfPT', 
      //initial sorting direction 
      sortorder: 'asc', 
      //we want to display total records count 
      viewrecords: true, 
      //grid height 
      height: '300px', 
      width : 1000, 
      rownumbers: true, 
      //scroll: true, 
      cellEdit:true, 
      cellurl: 'Edit', 


      loadComplete: function() { 
       if (idToSelect) { 
       $(this).jqGrid('setSelection', idToSelect); 
       //$("#" + $.jgrid.jqID(idToSelect)).effect("highlight", {}, 3000); 
       idToSelect = undefined; 
       } 
      } 

$('#jqgProducts').jqGrid('navGrid', '#jqgpProducts', 
      { add: true, 
       del: true, 
       edit:true, 
       search: true 

       }, 

{width: '450', url: '@Url.Action("Create")', closeAfterAdd: true, 

      closeAfterEdit: true, 

      reloadAfterSubmit: false, 

      afterSubmit: function (response) { 
       return [true, '', response.responseText]; 
      }, 


      addedrow: "last", // add new row at the end of grid 

      afterComplete: function (response, postdata) { 

       var gridId = this.gbox.substr(6); 

       $('#' + gridId).jqGrid('setSelection', postdata.id); 
      }, 




      afterSubmit: function (response) { 

      idToSelect = response.responseText; 
      return [true, '', response.responseText]; 
      } 

     }; 
    ); 
    }); 

감사합니다.

답변

0

클라이언트 측을 설정할 수 있습니다 :

sortname: 'yourSortingColum' 
sortorder: 'asc' || sortorder:'desc' 
관련 문제