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

Dynamically change the page size of the grid

3 Answers 530 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Svetlin
Top achievements
Rank 1
Svetlin asked on 04 Sep 2013, 03:48 AM
Hi there,

I have a grid with pageable option:

totalItemsInDb = null;

        pageable: pageSizes:
            [10, 50, 500, totalItemsInDb]
         },

 

After the grid is created I want to change the last on to
some specific number which is a result from the datasource call.

 dataSource: {
            change: function(e) {
                //totalItemsInDb = this.total();
            },
 

$("select[data-role='dropdownlist']").children("option").eq(3).val(totalItemsInDb);

$("select[data-role='dropdownlist']").children("option").eq(3).text("some string");

 

However, the change is not getting reflected on the pageable
drop down. If I inspect with dev tools I can see that the value and the txt are
changed, but they are not visible to the user. I tried to do .refresh() on the
grid but no change is visible. Any advice

Thank you

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 04 Sep 2013, 11:15 AM
Hello Svetlin,

The Kendo UI Grid uses a Kendo UI DropDownList for its pager. So setting the values using standart jQuery selectors will not affect the widget. If you want to read more about the DropDownList please follow this link:

http://docs.kendoui.com/getting-started/web/dropdownlist/overview

In your case you will need to get the reference of the Kendo UI DropDownList and add the values that you need to the dataSource of the widget. It should be something like this:

$("select[data-role='dropdownlist']").data('kendoDropDownList').dataSource.add({text: "5", value: "5"})

The above code will add 5 pages as an option in the Grid's pager dropdown.

I hope this helps.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Svetlin
Top achievements
Rank 1
answered on 04 Sep 2013, 04:20 PM
You are the best Kiro :)
0
Kiril Nikolov
Telerik team
answered on 05 Sep 2013, 06:46 AM
Hello Svetlin,

I am glad it helps!

If you have any further questions, do not hesitate to contact us.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Svetlin
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Svetlin
Top achievements
Rank 1
Share this question
or