Save TreeGrid data to json

Find code here before you post.

Save TreeGrid data to json

Postby support » Mon Oct 26, 2015 9:16 am

   
Class('App', 'xui.Com',{
Instance:{
iniComponents : function(){
// [[Code created by CrossUI RAD Studio
var host=this, children=[], append=function(child){children.push(child.get(0));};

append(
(new xui.UI.Pane())
.setHost(host,"ctl_pane6")
.setLeft(150)
.setTop(50)
.setWidth(360)
.setHeight(230)
);

host.ctl_pane6.append(
(new xui.UI.TreeGrid())
.setHost(host,"ctl_treegrid2")
.setRowNumbered(true)
.setHeader([{
"id" : "col1",
"width" : 80,
"type" : "input",
"caption" : "col1"
},{
"id" : "col2",
"width" : 80,
"type" : "input",
"caption" : "col2"
},{
"id" : "col3",
"width" : 80,
"type" : "input",
"caption" : "col3"
},{
"id" : "col4",
"width" : 80,
"type" : "input",
"caption" : "col4"
}])
.setRows([{
"cells" : [{
"value" : "row1 col1"
},{
"value" : "row1 col2"
},{
"value" : "row1 col3"
},{
"value" : "row1 col4"
}]
},{
"cells" : [{
"value" : "row2 col1"
},{
"value" : "row2 col2"
},{
"value" : "row2 col3"
},{
"value" : "row2 col4"
}]
},{
"cells" : [{
"value" : "row3 col1"
},{
"value" : "row3 col2"
},{
"value" : "row3 col3"
},{
"value" : "row3 col4"
}],
"sub" : [{
"cells" : ["sub1","sub2","sub3","sub4"]
}]
}])
);

append(
(new xui.UI.HTMLButton())
.setHost(host,"ctl_htmlbutton1")
.setLeft(280)
.setTop(300)
.setWidth(100)
.setHeight(22)
.setHtml("Save Data")
.onClick("_ctl_htmlbutton1_onclick")
);

return children;
// ]]Code created by CrossUI RAD Studio
},
_ctl_htmlbutton1_onclick:function (profile, e, value){
var ns = this;

var header = ns.ctl_treegrid2.getHeader("min"),
rows = ns.ctl_treegrid2.getRows("min");

var header2 = ns.ctl_treegrid2.getHeader("data"),
rows2 = ns.ctl_treegrid2.getRows("data");

alert(_.serialize({header:header, rows:rows}));
alert(_.serialize({header:header2, rows:rows2}));
}
}
});
   
support
 
Posts: 319
Joined: Sat Apr 27, 2013 9:22 am

Return to CrossUI Code Snaps

Who is online

Users browsing this forum: No registered users and 1 guest

cron