Santhosh
Santhosh

Reputation: 20436

Client Side Templates in javascript how to bind data

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.

Upvotes: 0

Views: 403

Answers (2)

Luke Schafer
Luke Schafer

Reputation: 9265

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 :)

Upvotes: 0

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827476

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.

Upvotes: 1

Related Questions