:: Forum >>

Updating data model question

Below is a template i wrote to allow only numeric input
When I used this template with a javascript array as the data model everything worked fine

However when used with xml I am unable to update the table model the error is on the line marked (1)

I am not very proficient with java script and any help is greatly appreciated.

Thank you

if (!window.Prima) Prima=[];
if (!Prima.Templates) Prima.Templates=[];

Prima.Templates.NumberInput = Active.Templates.Text.subclass();

Prima.Templates.NumberInput.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()
    
{
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
}

obj.setEvent("ondblclick", switchToEditMode);

function switchToTextMode()
    
{
var value = editor.element().value;
        var intVal = value * 1;

        if(!isNaN(intVal))
        {
            //alert(intVal);
            template.setItemProperty("text", value); ---- (1)
        }
        template.refresh();
        template = null;
}

editor.setEvent("onblur", switchToTextMode);
};

Prima.Templates.NumberInput.create();
Bhaskar
Friday, July 23, 2004

Buddy, What are you upto?

To my knowledge, Active.XML.Table is read only.

table.js line# 176
obj.getText = function(i, j){
        var node = this.getNode(i, j);
        var data = node ? node.text : "";
        var format = this._formats[j];
        return format ? format.dataToText(data) : data;
    };


And I don't see any setText method (bump...)

Sudhaker Raj
Saturday, July 24, 2004
Exactly I tried it with array and would also like to try it with xml and was asking how this could be done.

Thanks
Bhaskar
Sunday, July 25, 2004
Hi,

I just realized that may be I could rephraze my question.

I would like to edit the grid which is possible using the editor described above. I do not really require to update the data model as long as I can update the grid to display the new value.

Once again thank you for your response
Bhaskar
Sunday, July 25, 2004

I guess, in your code at (1)

template.setItemProperty("value", value);

will do the trick, but grid.refresh() will loose the new value.
Sudhaker Raj
Sunday, July 25, 2004
I tried that and I could not get it to work.
Alex, I think I saw a message where you had written some code for manipulating the xml. I am however unable to locate that code in the forum at this time. Can you please provide the link or code here

Thanks
Bhaskar
Monday, July 26, 2004
Hey I think I found it

http://www.activewidgets.com/messages/1621-0.htm
Bhaskar
Monday, July 26, 2004
Yes, this is it. You have to implement setText method on the XML data model.
Alex (ActiveWidgets)
Monday, July 26, 2004

This topic is archived.


Back to support forum

Forum search