• Resolved charles godwin

    (@charlesgodwin)


    I want to add a custom button to a publication. I want this button to open a WP page in a new tab and pass the export information (all rows or selected rows) as the value in a querystring name/value pair.

    I’ve got a button to work for the open but how can I get the query string of the records?

    A bonus question. I’d really like to only send three columns of selected rows, not all columns.

    Here’s what I have so far.

    
    	"wpda_buttons_custom": [
    		{
    			"text": "Link",
    			"action": "function ( e, dt, node, config ) {  window.open('https://testdb.ogs.on.ca/thurso-test-premium', '_blank'); }"
    		}
    	]
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Charles,

    Here is a link to an example of the javascript code for a custom button:
    https://code-manager.com/code/?wpda_search_column_code_type=front-end_code

    This is for the export button on the Code Manager website.

    This is how you select all rows:
    table = jQuery(‘#<your-table-id-goes-here>’).DataTable();
    rows = table.rows();
    data = rows.data();

    This is how you select only selected rows:
    table = jQuery(‘#<your-table-id-goes-here>’).DataTable();
    rows = table.rows({selected:true});
    data = rows.data();

    And this is the JSON for the Code Manager export publication:

    {
    	"dom": "lBfrtip",
    	"wpda_search_placeholder_prefix": "",
    	"wpda_searchbox": "footer",
    	"select": {
    		"selector": "td:not(.wpda_select)",
    		"style": "multi" 
    	},
    	"wpda_buttons_custom": [
    		{
    			"text": "Download selected code",
    			"className": "cm_button_download",
    			"action": "function ( e, dt, node, config ) { code_manager_export(); }",
    			"titleAttr": "Click row to select or deselect (multiple row selection supported)"
    		}
    	],
    	"initComplete": "function(settings, json) { jQuery('.cm_button_download').tooltip(); }"
    }

    If you want to export only selected columnm, just add column selection. Here is the documentation:
    https://wpdataaccess.com/docs/documentation/data-publisher/adding-buttons-premium/#adding-column-selection

    Does this help?

    Best regards,
    Peter

    Thread Starter charles godwin

    (@charlesgodwin)

    Thanks. you’ve given me a lot to think about.

    BTW I tried the download button on the first URL but nothing happened except the tooltip showed. I had selected the row I wanted.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Thank you for reporting Charles. I forgot to take the url argument into account. I fixed it! Can you please try again…

    Thanks,
    Peter

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exporting to a querystring’ is closed to new replies.