XML and drop down menu - please help
i work at a grid with data from XML ; i've read /javascript.forum.1621.5/editable-templates-with-xml-data.html
and i have implemented setText() method but :<<
var select = new My.Templates.Select;
select.setOptionsProperty("texts", ["1", "2", "3", "4", "Nessuno"]);
select.setOptionsProperty("values", ["1", "2", "3", "4", " "]);
select.setOptionsProperty("count", 5);
obj.setColumnTemplate(select, 2);>>
doesn't work
any idea?
thx
my complete script:
<script>
var table = new Active.XML.Table;
table.setURL("uploads/atest.xml");
table.request();
var columns = ["SCUOLA","CDCSCUOLA","ORDINE","DENOMINAZIONE","INDIRIZZO","SERVIZIO","FORM","TEL_R","TEL_D","CAP_R"];
var obj = new Active.Controls.Grid;
obj.setId("maingrid");
obj.setColumnProperty("texts", columns);
/* Need to add this so objects edited in grid customization don't get change if user cancels */
function clone (deep) {
var objectClone = new this.constructor();
for (var property in this)
if (!deep)
objectClone[property] = this[property];
else if (typeof this[property] == 'object')
objectClone[property] = this[property].clone(deep);
else
objectClone[property] = this[property];
return objectClone;
}
Object.prototype.clone = clone;
obj.setEvent("onkeydown", null);
obj.styleSheet = document.styleSheets[document.styleSheets.length-1];
obj.getTemplate("top").setEvent("onselectstart", obj.getEvent("onselectstart"));
obj.setEvent("onselectstart", null);
obj.getTemplate("row").setEvent("onmouseover", "mouseover(this, 'active-row-highlight')");
obj.getTemplate("row").setEvent("onmouseout", "mouseout(this, 'active-row-highlight')");
obj.alternateColors = ["#fff8f8", "#f8fff8", "#f8f8ff"];
obj.alternate = function(){ return obj.alternateColors[this.getProperty("row/order") % obj.alternateColors.length]; }
obj.getTemplate("row").setStyle("background", obj.alternate);
var select = new My.Templates.Select;
select.setOptionsProperty("texts", ["1", "2", "3", "4", "Nessuno"]);
select.setOptionsProperty("values", ["1", "2", "3", "4", " "]);
select.setOptionsProperty("count", 5);
obj.setColumnTemplate(select, 2);
//var selectTemplate = new My.Templates.StatusSelect;
//selectTemplate.addOption('Test 1','0001')
//selectTemplate.addOption('Test 2','0002')
//selectTemplate.addOption('Test 3','0003')
//obj.setColumnTemplate(selectTemplate,2);
obj.setColumnTemplate(new My.Templates.Input, 1);
obj.setColumnTemplate(new My.Templates.Input, 3);
function myColor(){ var value = this.getItemProperty('value'); return value == '' ? 'yellow' : 'white';}
obj.getColumnTemplate(1).setStyle('background-color', myColor);
obj.getColumnTemplate(3).setStyle('background-color', myColor);
obj.getColumnTemplate(7).setStyle('background-color', myColor);
table.setText = function(value, i, j){
var node = this.getNode(i, j);
node.text = value;
}
obj.setDataModel(table);
document.write(obj);
</script>
and i have implemented setText() method but :<<
var select = new My.Templates.Select;
select.setOptionsProperty("texts", ["1", "2", "3", "4", "Nessuno"]);
select.setOptionsProperty("values", ["1", "2", "3", "4", " "]);
select.setOptionsProperty("count", 5);
obj.setColumnTemplate(select, 2);>>
doesn't work
any idea?
thx
my complete script:
<script>
var table = new Active.XML.Table;
table.setURL("uploads/atest.xml");
table.request();
var columns = ["SCUOLA","CDCSCUOLA","ORDINE","DENOMINAZIONE","INDIRIZZO","SERVIZIO","FORM","TEL_R","TEL_D","CAP_R"];
var obj = new Active.Controls.Grid;
obj.setId("maingrid");
obj.setColumnProperty("texts", columns);
/* Need to add this so objects edited in grid customization don't get change if user cancels */
function clone (deep) {
var objectClone = new this.constructor();
for (var property in this)
if (!deep)
objectClone[property] = this[property];
else if (typeof this[property] == 'object')
objectClone[property] = this[property].clone(deep);
else
objectClone[property] = this[property];
return objectClone;
}
Object.prototype.clone = clone;
obj.setEvent("onkeydown", null);
obj.styleSheet = document.styleSheets[document.styleSheets.length-1];
obj.getTemplate("top").setEvent("onselectstart", obj.getEvent("onselectstart"));
obj.setEvent("onselectstart", null);
obj.getTemplate("row").setEvent("onmouseover", "mouseover(this, 'active-row-highlight')");
obj.getTemplate("row").setEvent("onmouseout", "mouseout(this, 'active-row-highlight')");
obj.alternateColors = ["#fff8f8", "#f8fff8", "#f8f8ff"];
obj.alternate = function(){ return obj.alternateColors[this.getProperty("row/order") % obj.alternateColors.length]; }
obj.getTemplate("row").setStyle("background", obj.alternate);
var select = new My.Templates.Select;
select.setOptionsProperty("texts", ["1", "2", "3", "4", "Nessuno"]);
select.setOptionsProperty("values", ["1", "2", "3", "4", " "]);
select.setOptionsProperty("count", 5);
obj.setColumnTemplate(select, 2);
//var selectTemplate = new My.Templates.StatusSelect;
//selectTemplate.addOption('Test 1','0001')
//selectTemplate.addOption('Test 2','0002')
//selectTemplate.addOption('Test 3','0003')
//obj.setColumnTemplate(selectTemplate,2);
obj.setColumnTemplate(new My.Templates.Input, 1);
obj.setColumnTemplate(new My.Templates.Input, 3);
function myColor(){ var value = this.getItemProperty('value'); return value == '' ? 'yellow' : 'white';}
obj.getColumnTemplate(1).setStyle('background-color', myColor);
obj.getColumnTemplate(3).setStyle('background-color', myColor);
obj.getColumnTemplate(7).setStyle('background-color', myColor);
table.setText = function(value, i, j){
var node = this.getNode(i, j);
node.text = value;
}
obj.setDataModel(table);
document.write(obj);
</script>
roberto
February 25,