Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting a YUI Button in DataTable

I've got a YUI DataTable with various columns that represents a list of users. I would like to add a column that contains a button in each row with a specific label (say, "grant access") and which invokes some function when clicked. Is this possible?

I've tried checking the YUI documentation, but as far as I can see, they don't allow you to change the label of the button itself in the way I allude to here. Any hints?

like image 556
Kyle Kaitan Avatar asked Feb 26 '26 03:02

Kyle Kaitan


1 Answers

In your column definitions, You should be able to specify a formatter ala

var myCols = [
    ... /* your other cols */
    {
        key: 'foo', formatter: function (cell, rec, col, data) {
            cell.innerHTML = '<button type="button">'+data+'</button>';
        }
    }
];

Custom formatters give you complete control over what is rendered into the cell. Also look at this example

like image 145
Luke Avatar answered Feb 28 '26 17:02

Luke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!