Placing HTML controls in a dataset column

I am new to servoy. My situation is, I am getting values from table to a dataset. In the dataset I am placing one html control which should trigger a method in another form. But the buttons placed and displayed in dataset don’t work.
Requesting for advice

dataSet.setValue(i,5,‘’+dataSet1.getMaxRowIndex()+‘’)…The onClick and hyperlink don’t work

I am displaying the result as this
forms.ichg_physical_items_line.displayResult=‘’+dataSet.getAsHTML()+'

Hi soumyamahakul,

First of all welcome to the Servoy forums :D

About your question.
Most common issue with non working links are that the display (HTML) field is not set to not-editable.

And if you are trying to trigger Servoy methods make sure you use the following syntax:

// when referencing a local method  - from the scope of the HTML field (!)
<a href="javascript:methodName()">some labeltext</a>

// referencing a method on another form
<a href="javascript:forms.formName.methodName()">some labeltext</a>

// referencing a global method
<a href="javascript:globals.methodName()">some labeltext</a>

dataSet.setValue(i,5,‘’+dataSet1.getMaxRowIndex()+‘’)

You use … for this specific value but when you display the dataset you also wrap it in one. So it seems you should only use the ‘+dataset1.getMaxRowIndex()+’'.

Hope this helps.

Mr Ivens,

It worked if the method is in the same form. Thank you very very much.

But it didn’t work for global or a method ina different form. I got the error message as “Couldn’t eval the string…”
Appreciate your advice.

Som

Hi Som,

soumyamahakul:
Mr Ivens,

Just call me Robert ;) .

soumyamahakul:
But it didn’t work for global or a method ina different form. I got the error message as “Couldn’t eval the string…”

Can you show me the HTML that didn’t work?

Ok Robert.

I did an application.output() and could see the results. This means the method worked for calling a method in another form.

For globals here is the code I am using:

dataSet.setValue(i,5,‘’+dataSet1.getMaxRowIndex()+‘’)

NumTapes method is defined and implemented in globals.js.

I tried to implement the same method (using <a href…) for buttin onClick event and it didn’t work. The button is pressed and nothing happens. Code below
dataSet.setValue(i,5,‘

’+dataSet1.getMaxRowIndex()+‘

’)

One more query:
Can I place a simple button (not a bean)on the form and write some functionalities like VB?

Thanks
Som

servoy_error.doc (139 KB)

Sorry for the dumb question on button. I have figured that out.

Robert,

Got one more query…

I tried to create my method with an argument. Servoy keeps on throwing error

//Throws error
function showname(var x)
{

globals.itemid=x
application.showForm(forms.LineDetail)

}

//No error but no result
function showname()
{

globals.itemid=x application.showForm(forms.LineDetail)

}

soumyamahakul:
For globals here is the code I am using:

dataSet.setValue(i,5,‘’+dataSet1.getMaxRowIndex()+‘’)

NumTapes method is defined and implemented in globals.js.

Javascript is caps sensitive. Is your global method indeed named ‘NumTapes’?

soumyamahakul:
I tried to implement the same method (using <a href…) for buttin onClick event and it didn’t work. The button is pressed and nothing happens. Code below
dataSet.setValue(i,5,‘

’+dataSet1.getMaxRowIndex()+‘

’)

onClick requires Javascript and the Sun HTML renderer does not support that.

Hope this helps.

Hi Som,

soumyamahakul:

//Throws error

function showname(var x)
{

globals.itemid=x
application.showForm(forms.LineDetail)

}

You can’t put variable arguments in the function name (only in custom functions inside methods). So you need to read the argument array in your code like so:

function showname()
{
	var x = arguments[0];
	globals.itemid=x
	application.showForm(forms.LineDetail)
	
}

Hi Robert,

It’s a learning. Don’t you think it’s strange declaring custom functions like this?

Anyway your advice is really giving me good results. It worked.

In my code I was trying argument[0] not arguments[0]. That’s why it was not working.

The arguments[0] in the method should be a universal data type which can hold any data type as we are not declaring any datatype. Like variant?

I am really thankful to you for taking time out and solving the queries.

Thanks
Som

Hi Som,

soumyamahakul:
It’s a learning. Don’t you think it’s strange declaring custom functions like this?

Methods can’t be defined with arguments in the function but any functions declared inside that method can have arguments in the function. I know it’s a bit odd, I guess this is a left over of how Servoy worked before 4.0.

The arguments[0] in the method should be a universal data type which can hold any data type as we are not declaring any datatype. Like variant?

The variable arguments is an Array and in Javascript an array can hold any datatype.

Thanks Robert.
Our discussion was very helpful to me.

Thanks again
Som