<script type='text/javascript'>
$('#tt').datagrid({ <br/>
title:'', <br/>
iconCls:'icon-edit', <br/>
width:'fit-content', <br/>
height:'500', <br/>
singleSelect:true, <br/>
idField:'id', <br/>
url:'<?php echo base_url(); ?>index.php/tempexcess/', <br/>
<br/><br/>
toolbar:[{<br/>
text:'Add New',<br/>
iconCls:'icon-add',<br/>
<br/>
handler:function(){<br/>
if($('#user_role').val()=='checker'){<br/>
alert('You don\'t have permission to do this operation !');<br/>
}<br/>
else if($('#user_role').val()=='maker'){ <br/>
insert();<br/>
}<br/>
}<br/>
<br/>
}<br/>
],<br/>
<br/>
columns:[[ <br/>
{field:'company_name',title:'Company Name',sortable:'true',<br/>
formatter:function(value){ <br/>
for(var i=0; i<company_namelist.length; i++){<br/>
if (company_namelist[i].company_name == value) return <br/>company_namelist[i].name;<br/>
}<br/>
return value; <br/>
}, <br/>
editor:{ <br/>
type:'combobox',<br/>
options:{<br/>
valueField:'company_name',<br/>
textField:'name',<br/>
data:company_namelist,<br/>
required:true,<br/>
onSelect:function(record){<br/>
<br/>
var row = $('#tt').datagrid('getSelected');<br/>
var rowIndex= $('#tt').datagrid('getRowIndex', row)<br/>
var editors = $('#tt').datagrid('getEditors', rowIndex);<br/>
<br/>
var leidEditor = editors[0];<br/>
$(leidEditor.target).combobox('setValue',record.company_name); <br/>
<br/>
}<br/>
} <br/>
}<br/>
<br/>
},<br/>
{field:'amount',title:'Amount',groupSeparator:' <br/>',options:"precision:2,groupSeparator:' ',decimalSeparator:'.'" <br/>,sortable:'true',width:100,editor : <br/>
{ type:'numberbox',<br/>
options:{<br/>
// precision:2 //,
groupSeparator:','<br/>
<br/>
}<br/>
}<br/>
<br/>
}, <br/>
onBeforeEdit:function(index,row){ <br/>
row.editing = true; <br/>
updateActions(index,row); <br/>
}, <br/>
onAfterEdit:function(index,row){ <br/>
row.editing = false; <br/>
updateActions(index,row); <br/>
}, <br/>
onCancelEdit:function(index,row){ <br/>
row.editing = false; <br/>
updateActions(index,row); <br/>
} <br/>
<br/>
}); <br/>
</script><br/>
键入单词autofill时,datagrid下拉列表无法正常工作,且数字格式无效
答案 0 :(得分:0)
对于数字格式问题,我找到了这个解决方案:
<script type='text/javascript'>
$('#tt').datagrid({
...
{field:'amount',title:'Amount',groupSeparator:,sortable:'true',width:100,
formatter:function(value,row,index) {
if(row.amount) {
return number_format(value,2,',','.');
}
}
}
...
}
...
function number_format(num,dig,dec,sep) {
x=new Array();
s=(num<0?"-":"");
num=Math.abs(num).toFixed(dig).split(".");
r=num[0].split("").reverse();
for(var i=1;i<=r.length;i++){x.unshift(r[i-1]);if(i%3==0&&i!=r.length)x.unshift(sep);}
return s+x.join("")+(num[1]?dec+num[1]:"");
}
...
</script>