|
Title: addRow on edatagrid Post by: jaimi 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? Title: Re: addRow on edatagrid Post by: jaimi 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? |