:: Forum >>
Editable templates with XML data model
It is possible to make editable templates (like this one -
http://www.activewidgets.com/messages/1394-8.htm ) working with XML data model as well. You just have to implement setText() method on the model:
table.setText = function(value, i, j){
var node = this.getNode(i, j);
node.text = value;
}
The code above is IE-specific, so we have to patch Mozilla to make it work there:
if (window.Element) {
Element.prototype.__defineSetter__("text", function(value){
this.firstChild.nodeValue = value;
});
}
Complete code based on 'xml-simple.htm' example would look like this:
var template = new My.Templates.Input;
var table = new Active.XML.Table;
table.setText = function(value, i, j){
var node = this.getNode(i, j);
node.text = value;
}
table.setURL("../data/companies-simple.xml");
table.request();
var columns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];
var obj = new Active.Controls.Grid;
obj.setColumnProperty("texts", columns);
obj.setColumnTemplate(template);
obj.setDataModel(table);
document.write(obj);
plus My.Templates.Input class from
http://www.activewidgets.com/messages/1394-8.htm
Alex (ActiveWidgets)
Friday, July 16, 2004
When you edit the table, is there a way to saveback the XML data to the file, or to a new file?
Matt
Wednesday, September 1, 2004
I don't know if JavaScript can do this. You need to use some server side code to do this.
Sudhaker Raj
Friday, September 10, 2004
I tried adding the setText method as described above, but it is never getting called. Do I have to call it explicitly when the data changes or should it be called automatically?
Lori
Tuesday, October 19, 2004
If you use editable template and call setItemProperty("text", value) there - it will result in data model setText(value, i, j) call.
template.setItemProperty("text", value) ->
grid.setDataProperty("text", value, i, j) ->
data.setText(value, i, j)
Alex (ActiveWidgets)
Tuesday, October 19, 2004
I want to add onkeydown event to the My.Templates.Input
to catch tab, enter, arrow keys...
I suppose this is a good start:
editor.setEvent("onkeydown", function() {
var ieCode = event.keyCode;
switch (ieCode)
{
case: '9': // TAB
// Do something
break;
// other cases....
}
});
my question is, How can I get access to the grid object to get
a: certain values from other cells in the same row
and b : switchToEditMode on the next editable field?
Koen dB
Wednesday, October 20, 2004
I could'n make the data write work on Netscape 7. If I don't patch with if (window.Element) {
Element.prototype.__defineSetter__("text", function(value){
this.firstChild.nodeValue = value;
});
}
the information does not go to XML data so I it get lost, but if I add the code the grid does not show any rows and give me this error
this.getProperty("data/text", _optionscol, this.getProperty("item/index")) has no properties
Lombardi
Friday, September 16, 2005
This topic is archived.
Back to support forum
Forum search