0

i 시작 jqgrid. 페이지에 jqgrid와 버튼이 하나 있습니다. 나는 사용자가 행 row1, row2, row3, ...을 편집하고 버튼을 클릭 할 때 버튼을 클릭하여 데이터 rows1,2,3을 서버에 보내길 원한다. 하지만 사용자 편집 행이 데이터를 서버로 보낼 때 jqGrid. 제 문제에 대한 해결책을주세요. 덕분에이 코드를 쓰기 모든jqgrid에서 인라인 편집을 사용할 때 서버에 모든 데이터를 보내는 방법

var mydata = [ 
{ id: "1", REQUEST_ID: "2007-10-01", WAYBILL_NO: "test", COST_ID: "note", COST_NAME: "200.00", COST_AMOUNT: "10.00", Subcategory: "1" }, 
{ id: "2", REQUEST_ID: "2007-10-02", WAYBILL_NO: "test2", COST_ID: "note2", COST_NAME: "300.00", COST_AMOUNT: "20.00", Subcategory: "2" }, 
{ id: "3", REQUEST_ID: "2007-09-01", WAYBILL_NO: "test3", COST_ID: "note3", COST_NAME: "400.00", COST_AMOUNT: "30.00", Subcategory: "1" }, 
{ id: "12", REQUEST_ID: "2007-09-10", WAYBILL_NO: "test11", COST_ID: "note12", COST_NAME: "500.00", COST_AMOUNT: "30.00", Subcategory: "1" } 
]; 



      var localstr = "0:Select Ones;"; 
      localstr += "1:Dollar"; 
      localstr += ";2:Pond"; 
      localstr += ";3:Youro"; 
      localstr += ";4:Derham"; 

      var lastSel; 
      var grid = jQuery("#list"); 
      grid.jqGrid({ 

       datatype: "local", 
       data: mydata, 
       ajaxGridOptions: { cache: false }, 
       loadonce: true, 
       direction: "rtl", 


       height: 'auto', 
       colNames: ['RequestID', 'WayBillNo', 'CostId', 'CostName', 'Amount', 'CurrencyUnit '], 
       colModel: [ 
        { name: 'REQUEST_ID', width: 100, sortable: true, hidden: true }, 
         { name: 'WAYBILL_NO', width: 100, sortable: true, hidden: true }, 
         { name: 'COST_ID', index: 'COST_ID', width: 200, sortable: true, hidden: true }, 
         { name: 'COST_NAME', width: 200, sortable: true }, 
         { name: 'COST_AMOUNT', width: 100, sortable: true, editable: true }, 
         { name: 'Subcategory', index: 'Subcategory', width: 200, formatter: 'select', editable: true, edittype: 'select', editoptions: { value: localstr} } 
       ], 
       sortname: 'Name', 
       viewrecords: true, 
       rownumbers: true, 
       sortorder: "desc", 
       editurl: 'clientArray', 
       onSelectRow: function (id) { 

        if (id && id !== lastSel) { 

         grid.saveRow(lastSel, true, 'clientArray'); 

         grid.jqGrid('restoreRow', lastSel); 
         grid.jqGrid('editRow', id, true, null, null, 'clientArray'); 
         lastSel = id; 

        } 


       }, 

       pager: '#pager', 
       caption: "" 
      }).jqGrid('navGrid', '#pager', { edit: true, add: true, del: false, search: false, refresh: false }); 

하지만 clientArray이며, 어떻게 clientArray 이노 데이터를 사용하여 서버에 보낼 수 있습니까 ?? 도와 주셔서 감사합니다.

답변

0

당신은

당신이 그리드

에서 읽은 데이터이

onSelectRow: function (id) { 
        if (id && id !== lastSel) { 
         grid.jqGrid('restoreRow', lastSel); 
         grid.saveRow(lastSel,true,'clientArray'); 
         grid.jqGrid('restoreRow',lastSel); 

         grid.jqGrid('editRow', id, true, null, null, 'clientArray'); 

        } 
       }, 

과 코드를 변경하는 모든 데이터는 모든 데이터가 서버로 전송이 버튼의 사용자 클릭에 대한 그 생성 버튼 후 그리드에 변경 저장할 수 있습니다

$("#btnSave").click(function(){ 
    var row=$("#list").jqGrid('getRowData',1); 
alert(row.cost_id) 
}); 
관련 문제