<Script type = "text/javascript"> function formatProgress (value) {if (value) {var s = '<div style = "width: 100%; border: 1px solid # ccc "> '+' <div style =" width: '+ value +' %; background: # cc0000; color: # fff "> '+ value +' % '+' </div>'' </div> '; return s;} else {return '';}} var editingId; function deleteRow () {if (editingId! = Undefined) {$ ('# tg '). treegrid ('select', editingId); return;} var row = $ ('# tg '). treegrid ('getselected'); if (row) {editingId = row. id $ ('# tg '). treegrid ('delete', editingId); $ ('# tg '). treegrid ('reloadfooter ');} $ (". actionbtn "). toggleClass ("l-btn-disabled");} function edit () {if (editingId! = Undefined) {$ ('# tg '). treegrid ('select', editingId); return;} var row = $ ('# tg '). treegrid ('getselected'); if (row) {editingId = row. id $ ('# tg '). treegrid ('ineinedit ', editingId);} $ (". actionbtn "). toggleClass ("l-btn-disabled");} function insert () {if (editingId! = Undefined) {$ ('# tg '). treegrid ('select', editingId); return;}/**/var rows = $ ('# tg '). treegrid ('getchildren '); editingId = rows. length + 1; var row = null; var _ data = {"id": editingId, "name": "new name", "persons": 0, "begin ": "3/19/2010", "end": "3/20/2010", "progress": 10}; var _ parentId = 0; var row = $ ('# tg '). treegrid ('getselected'); if (row) {$ ('# tg '). treegrid ('expand', row. id); _ parentId = row. id;} else {var root = $ ('# Tg '). treegrid ('getroot'); _ parentId = null ;}$ ('# tg '). treegrid ('append', {parent: _ parentId, // you can specify the parent ID here for data: [_ data]}); $ ('# tg '). treegrid ('ineinedit ', _ data. id); $ (". actionbtn "). toggleClass ("l-btn-disabled");} function save () {if (editingId! = Undefined) {var t = $ ('# tg'); t. treegrid ('enabled', editingId); editingId = undefined; var persons = 0; var rows = t. treegrid ('getchildren '); for (var I = 0; I <rows. length; I ++) {var p = parseInt (rows [I]. persons); if (! IsNaN (p) {persons + = p ;}} var frow = t. treegrid ('getfooterrows ') [0]; frow. persons = persons; t. treegrid ('reloadfooter '); $ (". actionbtn "). toggleClass ("l-btn-disabled") ;}} function cancel () {if (editingId! = Undefined) {$ ('# tg '). treegrid ('canceledit', editingId); editingId = undefined;} $ (". actionbtn "). toggleClass ("l-btn-disabled") ;}</script> <div style = "margin: 10px 0;"> <a href = "javascript: void (0) "disabled =" disabled "class =" easyui-linkbutton actionbtn "onclick =" save () "> Save </a> <a href =" javascript: void (0) "disabled =" disabled "class =" easyui-linkbutton actionbtn "onclick =" cancel () "> Cancel </a> </div>