Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you handle row onclick events using Flexigrid?

My flexigrid is setup. All I need is an event that gets called when the user clicks on a row. From there, I will send the user to another page based on the data contained in that row. But I can't seem to find any examples on how to do this.

I'm looking for a clear example on how to handle row onclick events using flexigrid.

I'm also interested in any other javascript table frameworks that could be used in this situation. I've been taking a peek at DataTables and it looks like it may be a better alternative (and the project appears to be more active)

like image 390
whoabackoff Avatar asked Jun 08 '11 14:06

whoabackoff


3 Answers

In the initial setup for the flexigrid, add the attribute process: procMe to the column model. Example:

colModel : [
    { display: 'Request', name : 'id', process: procMe }
]

and then create a callback:

function procMe( celDiv, id ) {
    $( celDiv ).click( function() {
        alert( id );
    });
}
like image 184
whoabackoff Avatar answered Nov 15 '22 18:11

whoabackoff


A better solution

Adding process to colModel didnt work for me.

colModel : [
{ display: 'Request', name : 'id', process: procMe }
]

this solution below is what I'm using:

var gridRows = $("#data-grid tbody tr");

gridRows.click(function (event) {
  displaySelectedItem($(this).attr('id').substr(3));
  return false; //exit
});
like image 22
zulucoda Avatar answered Nov 15 '22 16:11

zulucoda


Flexigrid column as link

colModel: [
        {
            display: 'DomainName', name: 'DomainName', width: 180, 
            sortable: true, align: 'left', 
            process: function (col, id) 
                     {
                       col.innerHTML = "<a href='javascript:domainEdit(" + id + ");' 
                                   id='flex_col" + id + "'>" + col.innerHTML + "</a>";
                     }
        }]

Link Function

function domainEdit(domainID) {
    alert('domainID' + domainID);
}
like image 1
dynamiclynk Avatar answered Nov 15 '22 16:11

dynamiclynk