This is a migrated thread and some comments may be shown as answers.

Setting Pager 'pageSizes' property via data attribute

4 Answers 15 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 24 Jan 2014, 10:46 PM
I'm attempting to set the pageSizes property of the Pager widget via the data attribute "data-page-sizes". It works if I set it to a literal array, such as:
data-page-sizes="[15,30,60]"
But, it doesn't work if I try to set it to a javascript variable, such as:
data-page-sizes="myPageSizes"
How can I set this property to a javascript variable with the data attribute ?

Here's a js.bin example:  http://jsbin.com/aruTaWOZ/1/edit

4 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 28 Jan 2014, 12:39 PM
Hello Josh,

I am afraid that what you would like to achieve is not supported - it is not possible to assign a JavaScript to the pageSizes option via data attribute. The value should be either literal array or boolean.
data-page-sizes="[15,30,60]"
data-page-sizes="false"

Please accept my apology for the inconvenience caused.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Josh
Top achievements
Rank 1
answered on 28 Jan 2014, 02:33 PM
Thanks Alexander.

I can work around this issue by setting it via script, versus data attribute initialization. However, that brings me to a question. This does work via script:

$("#pager-strings").kendoPager({
    pageSizes: myPageSizes,
    ...

So, it would seem the data attribute initialization does not have 100% parity with setting properties via script. I had assumed they were meant to be equal. Is that a bad assumption, or is this a bug?
0
Alexander Valchev
Telerik team
answered on 28 Jan 2014, 03:09 PM
Hi Josh,

Data attributes should be parsed before they are passed to the initialization method. The way options are parsed is connected with the expected value of the configuration property - pageSizes accepts only a boolean or array.

That said, the data attribute initialization has given differences compared to the JavaScript one. Using JavaScript is always the more flexible way, however we did our best to provide the developer an ability to set the options via data attributes too.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Josh
Top achievements
Rank 1
answered on 28 Jan 2014, 04:12 PM
Got it. Thank you for the extra information. :)
Tags
General Discussions
Asked by
Josh
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Josh
Top achievements
Rank 1
Share this question
or