// ****************************************************************
// Input Cell Template.
// ****************************************************************
My.Templates.Input = Active.Templates.Text.subclass();
My.Templates.Input.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setAttribute("value", function(){
return template.getItemProperty("text");
});
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
editor.setEvent("ondblclick", editor.element().focus());
obj.setEvent("ondblclick", switchToTextMode);
editing=true;
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode(){
var value = editor.element().value;
template.setItemProperty("text", value);
template.refresh();
template = null;
obj.setEvent("ondblclick", switchToEditMode);
editing=false;
}
function doNothing(){
editor.element().focus();
}
editor.setEvent("onblur", switchToTextMode);
};
// make input box selectable
obj.getTemplate("top").setEvent("onselectstart", obj.getEvent("onselectstart"));
obj.setEvent("onselectstart", null);
// *************************************************
// Input Cell Template.
// ***************************************************
My.Templates.Input = Active.Templates.Text.subclass();
My.Templates.Input.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setAttribute("value", function(){
return template.getItemProperty("text");
});
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().className += " active-edit-mode ";
template.element().innerHTML = editor;
editor.element().focus();
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode(){
var value = editor.element().value;
template.setItemProperty("text", value);
template.refresh();
template = null;
}
editor.setEvent("onblur", switchToTextMode);
};
table.setText = function(value, i, j){
// File/Folder Name Edit box
if (j== 2) {
var node = this.getNode(i, j);
if (value != node.text) {
node.text = value;
var nodeID = obj.getDataProperty("text", i, 0);
frames(0).location.href = "./nodeOperations.asp?nodeID=" + nodeID + "&Operation=Rename&newValue="+ value ;
frames(1).location.reload();
}
}
}
editor.setEvent("ondblclick", editor.element().focus());
//after
editor.element().focus();
///Probably you can fire a custom action:
function switchToTextMode()
{
...
this.action("myAction")
...
}
///and attach a handler to the grid object when it is created:
grid.setAction("myAction", function(src){
var gridRef = this;
var cellRef = src;
}
this.action("DoAfterEdit");
// modify model to write data back to the XML
table.setText = function(value, i, j){
if (j== 2) {
var node = this.getNode(i, j);
node.text = value;
}
}
var oldvalue ="";
obj.setAction('click', function(src){
var rowsel = src.getRowProperty("index");
var colsel = src.getColumnProperty("index");
oldvalue = src.getDataProperty("text", rowsel, colsel);
}
obj.setAction("DoAfterEdit", function(src){
var rowsel = src.getRowProperty("index");
var colsel = src.getColumnProperty("index");
var newvalue = src.getDataProperty("text", rowsel, colsel);
if (oldvalue != newvalue){
var nodeID = obj.getDataProperty("text", i, 0);
frames(0).location.href = "./nodeOperations.asp?nodeID=" + nodeID + "&Operation=Rename&newValue="+ newvalue ;
frames(1).location.reload();
}
}
This topic is archived.