TreeGrid, insertRows and modify column position.

Develop and Deploy Cross-Browser Web Apps .

TreeGrid, insertRows and modify column position.

Postby Sergei » Wed Oct 23, 2013 7:53 am

For example, there is a class:
javascript code
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
// Ensure that all the value of "key/value pair" does not refer to external variables
Instance:{
// To initialize instance(e.g. properties)
initialize : function(){
// To determine whether or not the com will be destroyed, when the first UI control be destroyed
this.autoDestroy = true;
// To initialize properties
this.properties = {};
},
// To initialize internal components (mostly UI controls)
// *** If you're not a skilled, dont modify this function manually ***
iniComponents : function(){
// [[Code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0));};

append((new xui.UI.TreeGrid())
.setHost(host,"ctl_treegrid14")
.setSelMode("single")
.setRowNumbered(true)
.setColMovable(true)
.setHeader([{"id":"owner", "width":80, "type":"label", "caption":"Owner"}, {"id":"family", "width":160, "type":"label", "caption":"FIO"}])
);

append((new xui.UI.SButton())
.setHost(host,"ctl_sbutton1")
.setLeft(360)
.setTop(10)
.setCaption("click me")
.onClick("_ctl_sbutton1_onclick")
);

return children;
// ]]Code created by CrossUI RAD Tools
},
// Give a chance to load other com
iniExComs : function(com, threadid){
},
// Give a chance to determine which UI controls will be appended to parent container
customAppend : function(parent, subId, left, top){
// "return false" will cause all the internal UI controls will be added to the parent panel
return false;
},
// This instance's events
events : {},
_ctl_sbutton1_onclick : function (profile, e, src, value) {
var uictrl = profile.boxing();
var stroka=[{"cells":[{"value":"isv", "caption":"isv", "id":"C235%owner"}, {"value":"Ivanov Ivan", "caption":"Ivanov Ivan Ivanivich", "proba":"probnoe pole", "id":"C235%family"}], "id":"235"}];
profile.host['ctl_treegrid14'].insertRows(stroka,null,null,false);
}
}
});

Pressing the button inserts a row. When manually performing modify column position further insertion of rows do not include changes to the sequence of columns. How to do to insertRows into account the new location of the columns?
Last edited by Sergei on Fri Oct 25, 2013 3:19 am, edited 1 time in total.
Sergei
 
Posts: 31
Joined: Sat Apr 27, 2013 9:48 am

Re: TreeGrid, insertRows and modify column position.

Postby support » Wed Oct 23, 2013 3:14 pm

You have to adjust rows data according to the current header.
support
 
Posts: 352
Joined: Sat Apr 27, 2013 9:22 am

Re: TreeGrid, insertRows and modify column position.

Postby Sergei » Thu Oct 24, 2013 9:20 am

Event _ctl_sbutton1_onclick can be rewritten. It seems to work.
javascript code
_ctl_sbutton1_onclick : function (profile, e, src, value) {
var uictrl = profile.boxing();
var stroka=[{"cells":[{"value":"isv", "caption":"isv", "id":"C235%owner"}, {"value":"Ivanov Ivan", "caption":"Ivanov Ivan Ivanivich", "proba":"probnoe pole", "id":"C235%family"}], "id":"235"}];

var my_tek_head=profile.host['ctl_treegrid14'].get(0).properties.header, new_str=[], pole_1;
for(var i65 in my_tek_head){if(my_tek_head.hasOwnProperty(i65)){
for(var i65_1 in stroka[0]){if(stroka[0].hasOwnProperty(i65_1) && (stroka[0][i65_1] instanceof Object)){
pole_1=i65_1;
for(var i65_2 in stroka[0][i65_1]){if(stroka[0][i65_1].hasOwnProperty(i65_2)){
if(my_tek_head[i65].id==stroka[0][i65_1][i65_2].id.substr(stroka[0][i65_1][i65_2].id.lastIndexOf('%')+1)) new_str.push(stroka[0][i65_1][i65_2]);
}}
}}
}}
stroka[0][pole_1]=new_str;
profile.host['ctl_treegrid14'].insertRows(stroka,null,null,false);
}
Sergei
 
Posts: 31
Joined: Sat Apr 27, 2013 9:48 am


Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 3 guests

cron