views:

157

answers:

2

I'm using Client Side templates in my JavaScript.

$create(Sys.UI.DataView, { data: data }, null, null, $get("id"));

Where i have JSON result in "data", which has 100 record. So ths template binding all the 100 record.

How can i efficiently pass required amount of data. ex: 10 record.

+1  A: 

You talk about 100 'records', that makes me think that data is an array, if so, you can get a portion of it, using the slice function:

$create(Sys.UI.DataView, { data: data.slice(0,10) }, null, null, $get("id"));

data.slice(0,10) will generate a new array, containing the first 10 elements of the original one.

CMS
ya absolutely ths is wat i need thnk very much..
santose
not sure how that answers your question, it actually creates more problems (kinda... see my answer)
Luke Schafer
A: 

you're not passing a copy of the data object, you're passing a reference to it. CMS's example creates a copy (if it's of objects, it's a copy of references which is ok but totally not required, if it's of value types then it's really inefficient, but who cares when it's only 10 records)

Basically, don't worry about it, it's fine :)

Luke Schafer