Add New Row to SlickGrid -


hi have tried these 2 codes inserting new row in slickgrid.

code-1:

data1.push({id: "12345", name: "seckey", field: "seckey", complete:true});         //grid1.setdata(data1);         //grid1.render(); 

it inserting undefined in slick grid cell..

code-2:

 try{             var rowdata = grid1.getdata();             //alert(rowdata+"rowdata");              newid = dataview1.getlength();             //alert(newid);             newrow.id = newid + 1;             //alert(newrow.id);             var newrow = {title: "new title"};             //alert(newrow);             dataview1.insertitem(newrow.id, newrow);             alert("end");             }catch(e){                 alert("error:"+e.description);             } 

the code-2 catches , gives error..let me know wat have code change.!

you can follows if using dataview,

 function addnewrow() {     dataview.additem({id: "12345", name: "seckey", field: "seckey", complete:true});     dataview.refresh(); } 

or can follows if not using dataview,

     function addnewrow() {         grid.getdata().splice(grid.getdatalength(), 1, {});         grid.invalidaterow(grid.getselectedrows());         grid.updaterowcount();         grid.render();     } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -