2016-07-15 17 views
0

保存する前に編集した最後のフィールド(最初にグリッドの他の部分をクリックしない場合)は、そのフィールドのデータがHTMLに置き換えられます。私は07/01/2016と入力し、00/00/0000として保存します。保存する前にフィールドを出力すると、日付の代わりに次のHTMLが表示されます。保存する前に別のセルをクリックしない限り、セルの日付は保存されません。解決策を教えてください。jqgrid - 保存前に編集するとセルデータが失われる

コード:

\t jQuery("#billing_schedule").jqGrid({ 
 
\t \t datatype: 'clientSide', 
 
     //datatype: 'local', 
 
\t \t //editurl: 'clientArray', 
 
\t \t cellEdit: true, 
 
\t \t cellsubmit: 'clientArray', 
 
     colNames:['','Date','Amount'], 
 
     colModel :[ 
 
      {name:'btn', index:'btn', width:90, sortable:false}, 
 
\t \t {name:'date', index:'date', sortable:false, width:125, editable:true, editoptions:{size:"20"}}, 
 
\t \t {name:'amount', index:'amount', sortable:false, width:120, editable:true, editoptions:{size:"20"}} 
 
\t \t ], 
 
\t  width: 350, 
 
\t \t height: 175, 
 
\t \t sortname:'date', 
 
\t \t sortorder: 'asc', 
 
\t \t viewrecords: true, 
 
     imgpath: 'css/images', 
 
\t \t caption: '', 
 
\t \t altRows: false, 
 
\t \t beforeEditCell: function(rowid, cellname, value, iRow, iCol) { 
 
\t \t \t cellIsInEditMode = true; 
 
\t \t \t editedRow = iRow; 
 
\t \t \t editedCol = iCol; 
 
\t \t }, 
 
\t \t afterSaveCell: function(rowid, cellname, value, iRow, iCol) { 
 
\t \t \t cellIsInEditMode = false; 
 
\t \t \t if (validateErrorPresent == true){ 
 
\t \t \t  \t jQuery("#billing_schedule").setCell(rowid,"date",validatedVar,{},{}); 
 
\t \t \t validateErrorPresent = false; 
 
\t \t \t } 
 
\t \t }, 
 
\t \t beforeSaveCell : function(rowid,celname,value,iRow,iCol) { 
 
\t \t  //validate 
 
\t \t \t if(iCol==1) { //standardize the date 
 
\t \t \t  
 
\t \t \t if(d==null){ 
 
\t \t \t  alert('Date string doesn\'t match any recognized formats!'); 
 
\t \t \t \t validateErrorPresent = true; 
 
\t \t \t \t validatedVar = "invalid"; 
 
\t \t \t \t //jQuery("#billing_schedule").setRowData(ids[i],{date:""}) 
 
\t \t \t } else { 
 
\t \t \t  var newval = formatDate(d,'M/d/yyyy'); 
 
\t \t \t  //jQuery("#billing_schedule").setRowData(rowid,{date:newval}) 
 
\t \t \t \t validatedVar = newval; 
 
\t \t \t \t validateErrorColName = "date"; 
 
\t \t \t \t validateErrorPresent = true; 
 
\t \t \t } 
 
\t \t \t } 
 
\t  }, 
 
\t \t gridComplete: function() { 
 

 
\t \t } 
 
\t 
 
     }); 
 
\t getExistingSchedule(); 
 

 
<?php 
 
\t $urlToGet = $urlAppPath."php/person_status_includes.php?request=docready&isStudent=1&personID=".$studentID; 
 
\t readfile($urlToGet); 
 
?> \t 
 
\t <?php 
 
if($scheduleID <> 0){ 
 
?> 
 
     \t  var currentTime = new Date(); 
 
     \t var seconds = currentTime.getTime(); 
 
    \t \t var s=htmlSendGrid(); 
 
     \t httpObject = getHTTPObject(); 
 
      if (httpObject != null) { 
 
       httpObject.open("GET", "php/predefined_schedules.php?action=get&scheduleID="+jQuery("#schedule_combo").val(), true); 
 
       httpObject.send(null); 
 
       httpObject.onreadystatechange = loadExistingSchedule; 
 
\t \t \t } 
 
<?php 
 
} 
 
?> 
 
\t 
 
\t \t $("a[rel]").overlay(); 
 

 
    });

答えて

0

IはsaveCellBeforeArrayを(追加)。 は私の保存機能に機能します

私はgetHTTPObjectを検索してデータベースを保存する前に、それはうまくいきました。私の基本的機能を保存します。

function onClickSave(){ 
     var ids = jQuery("#billing_schedule").getDataIDs(); 
     if (ids.length>0){   
     saveCellBeforeArray(); // fixed edit load problem 
     var ids = jQuery("#billing_schedule").getDataIDs(); 
     var s; 
     //load data from table 
     for(var i=0;i<ids.length;i++){ 
      s = s+"&paymentDate="+jQuery("#billing_schedule").getCell(ids[i],1)+"&paymentAmount="+jQuery("#billing_schedule").getCell(ids[i],2); 
     } 
     httpObject = getHTTPObject(); 
... 

\t jQuery("#billing_schedule").jqGrid({ 
 
\t \t datatype: 'clientSide', 
 
     //datatype: 'local', 
 
\t \t //editurl: 'clientArray', 
 
\t \t cellEdit: true, 
 
\t \t cellsubmit: 'clientArray', 
 
     colNames:['','Date','Amount'], 
 
     colModel :[ 
 
      {name:'btn', index:'btn', width:90, sortable:false}, 
 
\t \t {name:'date', index:'date', sortable:false, width:125, editable:true, editoptions:{size:"20"}}, 
 
\t \t {name:'amount', index:'amount', sortable:false, width:120, editable:true, editoptions:{size:"20"}} 
 
\t \t ], 
 
\t  width: 350, 
 
\t \t height: 175, 
 
\t \t sortname:'date', 
 
\t \t sortorder: 'asc', 
 
\t \t viewrecords: true, 
 
     imgpath: 'css/images', 
 
\t \t caption: '', 
 
\t \t altRows: false, 
 
\t \t beforeEditCell: function(rowid, cellname, value, iRow, iCol) { 
 
\t \t \t cellIsInEditMode = true; 
 
\t \t \t editedRow = iRow; 
 
\t \t \t editedCol = iCol; 
 
\t \t }, 
 
\t \t afterSaveCell: function(rowid, cellname, value, iRow, iCol) { 
 
\t \t \t cellIsInEditMode = false; 
 
\t \t \t if (validateErrorPresent == true){ 
 
\t \t \t  \t jQuery("#billing_schedule").setCell(rowid,"date",validatedVar,{},{}); 
 
\t \t \t validateErrorPresent = false; 
 
\t \t \t } 
 
\t \t }, 
 
\t \t beforeSaveCell : function(rowid,celname,value,iRow,iCol) { 
 
\t \t  //validate 
 
\t \t \t if(iCol==1) { //standardize the date 
 
\t \t \t  
 
\t \t \t if(d==null){ 
 
\t \t \t  alert('Date string doesn\'t match any recognized formats!'); 
 
\t \t \t \t validateErrorPresent = true; 
 
\t \t \t \t validatedVar = "invalid"; 
 
\t \t \t \t //jQuery("#billing_schedule").setRowData(ids[i],{date:""}) 
 
\t \t \t } else { 
 
\t \t \t  var newval = formatDate(d,'M/d/yyyy'); 
 
\t \t \t  //jQuery("#billing_schedule").setRowData(rowid,{date:newval}) 
 
\t \t \t \t validatedVar = newval; 
 
\t \t \t \t validateErrorColName = "date"; 
 
\t \t \t \t validateErrorPresent = true; 
 
\t \t \t } 
 
\t \t \t } 
 
\t  }, 
 
\t \t gridComplete: function() { 
 

 
\t \t } 
 
\t 
 
     }); 
 
\t getExistingSchedule(); 
 

 
<?php 
 
\t $urlToGet = $urlAppPath."php/person_status_includes.php?request=docready&isStudent=1&personID=".$studentID; 
 
\t readfile($urlToGet); 
 
?> \t 
 
\t <?php 
 
if($scheduleID <> 0){ 
 
?> 
 
     \t  var currentTime = new Date(); 
 
     \t var seconds = currentTime.getTime(); 
 
    \t \t var s=htmlSendGrid(); 
 
     \t httpObject = getHTTPObject(); 
 
      if (httpObject != null) { 
 
       httpObject.open("GET", "php/predefined_schedules.php?action=get&scheduleID="+jQuery("#schedule_combo").val(), true); 
 
       httpObject.send(null); 
 
       httpObject.onreadystatechange = loadExistingSchedule; 
 
\t \t \t } 
 
<?php 
 
} 
 
?> 
 
\t 
 
\t \t $("a[rel]").overlay(); 
 

 
    });

関連する問題