2013-01-18 19 views
1

我有一個jqgrid中的列的自定義格式化程序,處於編輯模式時,它始終對齊左側。我怎樣才能讓它對齊到正確的位置?如何使文本在jqgrid中處於編輯模式時向右對齊

這裏是colModal和自定義格式化程序的一部分,其中一些列是可編輯的。

colModel: [ { name: 'col10', width: '70px', fixed: true, align: right', 
        formatter:percentFomatter, editable: true }, 
    { name: 'col11', width: '70px', fixed: true, align: 'right', formatter: percentFomatter, editable: true }, 
    { name: 'col12', width: '70px', fixed: true, align: 'right' } ], function percentFomatter(cellvalue, options, rowObject) { return cellvalue + '%'; }; 
+0

請出示一些代碼 - 因此,我們將能夠更好地幫助你。 – Spontifixus

+0

這裏是colModal和自定義格式化程序的一部分,其中一些列是可編輯的。 謝謝。 colModel: \t \t {名稱: 'col10',寬度: '70像素',固定:真,對齊: '右',格式化:percentFomatter,編輯:真}, \t \t {名稱: 'col11' ,width:'70px',fixed:true,align:'right',formatter:percentFomatter,editable:true}, \t \t \t \t {name:'col12',width:'70px',fixed:true,align: 'right'} ], function percentageFomatter(cellvalue,options,rowObject){ return cellvalue +'%'; }; – user1990720

回答

2

您可以使用editoptions:{datainit: ...將樣式應用於正在編輯的元素。

例如

... 
... 
align: "right", 
editable:true, 
editoptions: {dataInit:function(e){ 
       e.style.textAlign = 'right';        
      }} 
... 
... 

我已經創建小的演示here