easyui edatagrid Set Default Value for Numberbox

315 Views Asked by At

Can anyone help me with a problem I am having. I'm using JEasyUI eDataGrid, and when inserting a new record I would like the numberbox fields to automatically have a 0 in them.

Table portion

<th field="Defect" width="50">Defect</th>

Script

 $(function(){
            $('#dg').edatagrid({
                url: ...
                emptyMsg: 'No Record(s) Found',
                columns:[[
  {field:'Defect',title:'Defect',width:100,
                      formatter:function(value,row){
                          return row.Defect|| value;
                      },
                      editor:{
                          type:'numberbox',
                          options:{
                              required:true,
                              min:0,
                            *value: 0,*

                          }

Looking through the documentation, adding a value property should set a default value but it does not.

1

There are 1 best solutions below

0
ohs2 On

Figured out the answer. What I needed to do was add the following to my script.

onBeginEdit: function(index,row){
                var ed = $(this).datagrid('getEditor',{index:index,field:'defect'});
                $(ed.target).numberbox('setValue', 0)
            
      
            },