2010-12-09 36 views
0

我有一列jqgrid定義爲數字。用戶被迫輸入一個像6.5的數字,逗號分隔符是一個點。 這個網格也被說德語的人用來插入這樣的數字6,5,用逗號作爲分隔符。jqgrid - 如何規避數字檢查

此人越來越心煩的時候都不會允許插入的6,5,而不是6.5:d

爲了讓自己(和結尾)我的生活更方便我在尋找一種方式來轉換自動6,5到6.5。這應該在客戶端完成,因爲我想依靠jqgrid數字檢查。

因此,我應該檢查(也許變換)之前jqgrid檢查它的數量。 這可能嗎?

- 編輯 - 這些函數

無是所謂的,除了第一個。 任何想法,爲什麼這可能是原因?

afterInsertRow:function (rowid, aData){ 
       alert('fire'); 

      }, 
    beforeSaveCell : function(rowid,celname,value,iRow,iCol){ 
       alert('no fire'); 
       return "new value"; 

     }, 
    beforeSubmitCell : function(rowid,celname,value,iRow,iCol){ 
       alert('no fire2'); 
       return "new value"; 

     }, 
    beforeEditCell : function(rowid,celname,value,iRow,iCol){ 
       alert('no fire3'); 
       return "new value"; 

     }, 

--edit2--

這是我使用內聯編輯的代碼。

onSelectRow: function(row_id){ 
if(row_id != null) { 
    var date_str = jQuery('#grid').getCell(row_id, 'date_str'); 
    //var sum = jQuery('#grid').getCell(row_id, 'sum'); 
    var description = jQuery('#grid').getCell(row_id, 'description'); 
    if(date_str != "Total"){ 
     if(row_id !== last_selected_row) { 
      if(row_id == -99){ 
       //thats the first click of the user after initial load of the grid 
       jQuery('#grid').jqGrid('saveRow',row_id) 
        .editRow(row_id, true,true,reload); 
       last_selected_row = row_id; 
         } 
      else{ 
       //after user jumps from one cell to another using the mouse 
       jQuery('#grid').jqGrid('saveRow',last_selected_row,reload); 
       jQuery('#grid').jqGrid('restoreRow',last_selected_row); 
       last_selected_row = row_id; 
      } 
     } else { 
      jQuery('#grid').jqGrid('saveRow',row_id) 
       .editRow(row_id, true,true,reload); 
      last_selected_row=row_id; 
        } 
      } 
     } 

},

+0

您可以清除**用戶輸入數字的位置嗎?你的意思是搜索(哪一個),form/inline/cell edditing,添加新行或其他東西? – Oleg 2010-12-09 16:20:30

+0

當用戶在單元格中輸入數字時。 - >因此單元格編輯 – 2010-12-09 16:31:58

回答

1

如果您使用的單元格編輯,你可以嘗試寫你beforeSaveCell事件,其做的文本替換你的需要。

修訂:我不知道哪些信息可以被放置在細胞內,但可能的Masked Input Plugin使用(見舊答案here),或者只是「按鍵」過濾(見another answer)可以改善用戶體驗。