EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Stefan B. on June 17, 2014, 02:37:01 AM



Title: How can I add a button to pagination at runtime
Post by: Stefan B. on June 17, 2014, 02:37:01 AM
How can I add a button to pagination at runtime?
If I use the following code the buttons on the pagination not changed (not view the new buttons).
It looks like the refresh not working for the buttons?

Code:
		pager = $('#'+eDatagridSelector).edatagrid('getPager');
var btns= pager.pagination('options').buttons;
btns.push(newButtonArray);
$('#'+eDatagridSelector).edatagrid('getPager').pagination('refresh', {
buttons: btns
});


Title: Re: How can I add a button to pagination at runtime
Post by: Stefan B. on June 17, 2014, 04:46:35 AM
I found selfthe solution that's working

Code:
	function _addButtons(eDatagridSelector, buttons) {
//get old buttons and change them
var edg = $('#'+eDatagridSelector);
var currentPagerButtons = edg.datagrid('getPager').pagination('options').buttons;
for (var i = 0; i < buttons.length; i++) {
currentPagerButtons.push(buttons[i]);
}

//set buttons with new buttons
edg.datagrid('getPager').pagination({ buttons: currentPagerButtons });
}