Button with regular link

Button with regular link

jhobrlantjhobrlant Posts: 5Questions: 1Answers: 0

Is there a way to use a button for a regular link? I already tryed this:

buttons: [ { text: "link", url: '../r2_tables/huk.cfm' }, ...

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    Answer ✓

    You could set the action function (buttons.buttons.action) of your custom button to set the window.location.href property.

    There isn't a link button type - but it sounds like a good option for a plug-in button type if you'd like to create one (and possibly share it with us :-) ).

    Allan

  • jhobrlantjhobrlant Posts: 5Questions: 1Answers: 0

    If I only could I would do this plugin. But my knowledge level lets me stick to the available options. And these are covering nearly all topics I faced so far.

    Thanks for this great framework!

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    Answer ✓

    would this work for you ?

    buttons: [ 
        {
          text: 'Link Button',
          action: function ( e, dt, button, config ) {
            window.location = 'linkpage.php';
          }         
        }
    ]
    
  • jhobrlantjhobrlant Posts: 5Questions: 1Answers: 0

    Thanks for the example, worked out of the box.

  • jhobrlantjhobrlant Posts: 5Questions: 1Answers: 0

    Is there a way to also know the selected rows, like for the "edit" button?

    My idea is to have 2 edit pages:
    - a Quick Edit to edit the most important fields of my table, therefore I am using the original Edit button and form
    - a Full Edit page outside of DT, that gives me full control over the 20+ fields

    I am using server side processing. Therefor I needed the selected rows ID's.

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    Answer ✓

    Is there a way to also know the selected rows, like for the "edit" button?

    Yes. The documentation for that is available here.

    Allan

  • jhobrlantjhobrlant Posts: 5Questions: 1Answers: 0

    OK, this is my final solution. Works as expected.

                            { extend: "edit", text: "Quick Edit",   editor: editor },
                            {
                              extend: "edit",
                              text: 'Full Edit',
                              enabled: false,
                              action: function ( e, dt, button, config ) {
                                var rows = dt.rows( { selected: true } ).count();
                                if (rows==0) {
                                } else {
                                    var myValue = dt.rows( { selected: true } ).data()[0].assetId;
                                    window.location = 'assets_edit_form.cfm?assetId='+myValue;
                                }
                              }        
                            },
    
This discussion has been closed.