Im using buttoned pageLength but how can I make them like a radiobtn?

Im using buttoned pageLength but how can I make them like a radiobtn?

PepayuPepayu Posts: 4Questions: 2Answers: 0

Basically what I want is

10 25 50

Side by side to each other. not

10
   10
   25
   50

like this

Answers

  • PepayuPepayu Posts: 4Questions: 2Answers: 0

    Hello again guys im so sorry for spamming the forum board, I'm just desperate. I manage to do this by :

        var table = new DataTable('#productTable', {
            layout: {
                bottomStart: {
                    buttons: [
                        {
                            text: '25',
                            attr: { id: '25' },
                            action: function (e, dt, node, config) {
                                table.page.len(25).draw();
                            }
                        },
                          {
                            text: '50',
                            attr: { id: '50' },
                            action: function (e, dt, node, config) {
                                table.page.len(50).draw();
                            }
                        }
                            ]
                }
            },
            stateSave: true,
            bFilter: false
    
        });
    

    Basically my main concern is im using stateSave and I want to preserve what the page length the user will click. So when I tried doing this via button type it works and the last length the user clicked is still there.

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    It's unclear from your last post if you are still having issues or not. I believe the page length should be saved when using the page.len() API. If you are having issues please provide a test case replicating the issues you are having so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    A while back I wrote a plugin called LengthLinks which might be of some interest. Demo here.

    It doesn't use the Buttons library like your solution though.

    Basically my main concern is im using stateSave and I want to preserve what the page length the user will click.

    The page length will be maintained, but you'll need to use buttons.buttons.init to set the initial state of the button (actually, you don't currently use button().active() to indicate if a button is active or not - you might want to consider doing that). You could add a draw listener in the button's init, and check if that button should be active or not.

    Sounds like a good blog post option - I've added it to my list.

    Allan

Sign In or Register to comment.