EasyUI Forum
December 16, 2025, 06:06:23 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: addRow on edatagrid  (Read 14267 times)
jaimi
Full Member
***
Posts: 121


View Profile
« on: September 11, 2012, 03:08:20 AM »

I created a edatagrid toolbar via markup.

<div id="tob_project" style="padding:0px;height:auto">
<div>
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
   onclick="javascript:$(\'#dag_project\').edatagrid(\'addRow\')">zufügen</a>
</div>';
 <div style="margin-left:5px">
...
</div>
</div>
But it won't add a new row to the table.

Then I added a button to the pager and added a function like this:
pager.pagination({
  showPageList: true,
  displayMsg  : '{from} bis {to} von {total} Projekten',
  buttons     :[
   {iconCls:'icon-add'   ,handler:function(){addProject();}},
   {iconCls:'icon-edit'  ,handler:function(){editProject();}},
   {iconCls:'icon-remove',handler:function(){removeProject();}},
   {iconCls:'icon-save'  ,handler:function(){saveProject();}},
   {iconCls:'icon-undo'  ,handler:function(){undoProject();}}
  ]
 });//pager

function addProject(){
 alert('add');
  $('#dag_project').edatagrid('addRow');
}//saveProject

The alert works but it still adds no row to the edatagrid.

Has anyone an idea?
Logged
jaimi
Full Member
***
Posts: 121


View Profile
« Reply #1 on: September 11, 2012, 03:38:59 AM »

I found the reason:

The table markup has for one field a formatter function like the one in the tutorial (now comment out):

<th field="PVA_END_FORMAT" width="090" sortable="true" data-options="editor:eDAT" ' /*formatter="formatProjectEnd"*/ . '>Ende</th>

function formatProjectEnd(val,row){

  var heute = new Date();
  var y = heute.getFullYear();
   var m = pad(heute.getMonth()+1, 2);
   var d = pad(heute.getDate(), 2);
   var formatHeute = y+m+d;

  formatFeld = val.substr(6,4)+val.substr(3,2)+val.substr(0,2);

   if (formatHeute > formatFeld){
        return '<span style="color:red;">'+val+'</span>';
   } else {
         return val;
   }//if
}//formatProjectEnd

I don't understand why the formatter restrains the addRow function from adding a new row.
Has anyone an idea?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!