PDA

View Full Version : Passing xindex value to another function.



ksvijaynkl
24 Jun 2011, 6:44 AM
I am trying to pass the "xindex" value to another function. But it is not getting affected.

<tpl for="scheduleList">'

{timeStamp:this.convertToDate(values,xindex)}

</tpl>

convertToDate: function(timeStamp,index) {

alert(index)
}

But the value of index coming as [object object].

How to retrieve the value of the current index in the convertToDate function

skirtle
24 Jun 2011, 7:02 AM
The two arguments that you're trying to pass here:


{timeStamp:this.convertToDate(values,xindex)}

aren't going to have any effect. It will pass the timeStamp as the first argument and the whole of the current object as the second argument. If you want to use xindex you need to be in a {[ ... ]} block, which this line isn't. There's an example of doing this in the docs for XTemplate.

ksvijaynkl
24 Jun 2011, 7:12 AM
The two arguments that you're trying to pass here:


{timeStamp:this.convertToDate(values,xindex)}

aren't going to have any effect. It will pass the timeStamp as the first argument and the whole of the current object as the second argument. If you want to use xindex you need to be in a {[ ... ]} block, which this line isn't. There's an example of doing this in the docs for XTemplate.


even i try to pass like {timeStamp:this.convertToDate(values,3)}, the convertToDate date function it is not taking it.
Can you tell me that, how to pass values to the convertToDate functions

skirtle
24 Jun 2011, 7:25 AM
You cannot pass arguments to a function in a template like that. Anything you put in parentheses after the function name will just be ignored. The arguments will always be timeStamp and the current object.

The only way to do what you want to do is to use a {[...]} block. Please read the documentation for the XTemplate constructor for how to do this.