How to add a custom export button to toolbar?

QuestionsHow to add a custom export button to toolbar?
Svilen Kirov asked 5 years ago

I want to use the same method as the default export button, however I want to change the icon and caption of the button.

I know the syntax for adding a custom toolbar button but what should I put in the function field?

On a side note is there a way to see all available icons?

jQuery(document).ready(function(){

jQuery(‘#list1’).jqGrid(‘navButtonAdd’, ‘#list1_pager’,
{
‘caption’ : ”,
‘buttonicon’ : ‘ui-icon-print’,
‘onClickButton’: function()
{
// what should i put here
},
‘position’: ‘last’
});
});

5 Answers
Abu Ghufran Staff answered 5 years ago

You can call this function inside onClickButton callback and can replace pdf with csv,xls,html.

jqgrid_process_export(‘pdf’);

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Svilen Kirov answered 5 years ago

This solution doesn’t seem to work, after I press button nothing happens.

jQuery(document).ready(function(){

jQuery(‘#list1’).jqGrid(‘navButtonAdd’, ‘#list1_pager’,
{
‘caption’ : ”,
‘buttonicon’ : ‘ui-icon-print’,
‘onClickButton’: function()
{
jqgrid_process_export(‘pdf’);
},
‘position’: ‘last’
});
});

Abu Ghufran Staff answered 5 years ago

Please check browser debug console for JS error and paste it here.
Are you using free version or full version?

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 5 years ago

You can also use:

window.open(“?grid_id=list1&export=1&jqgrid_page=1&export_type=html”);

where list1 is grid id and “html” is format to export, which could be pdf,csv,xls.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Svilen Kirov answered 5 years ago

Users.php:355 Uncaught ReferenceError: jqgrid_process_export is not defined
at HTMLTableElement.onClickButton (Users.php:355)
at HTMLTableCellElement.<anonymous> (jquery.jqGrid.min.js:9)
at HTMLTableCellElement.dispatch (jquery.min.js:3)
at HTMLTableCellElement.r.handle (jquery.min.js:3)

This was the error while using jqgrid_process_export(‘pdf’) and I am using the premium version, however with window.open(“?grid_id=list1&export=1&jqgrid_page=1&export_type=html”), everything seems to work just fine so thanks.

Your Answer

0 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?