Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flexigrid - adding a column with links

I'm using Flexigrid to display paginated data and it works very well. Now I need to add links to all the rows ("edit", "view", "delete") and honestly I have no idea how to proceed with it. Is there something that I could use right out of the box?

The basic idea is to have an additional column with small icons for those 3 links and not to have the toolbar at the top.

Any ideas?

like image 627
Matthias Hryniszak Avatar asked Jan 01 '26 06:01

Matthias Hryniszak


1 Answers

I've got it figured out :)

The trick is to simply put the link directly in the data returned by script. For example this will create a row with the first column containing the links in question:

List<Object> rows = new List<Object>();
foreach (var item in results) {
rows.Add(new { 
    id = item.ID,
    cell = new string[] { 
        String.Format("<a href='/Account/View/{0}'>view</a>&nbsp;<a href='/Account/Edit/{0}'>edit</a>", item.ID), 
        item.Name, 
        item.Phone 
    }
}
var result = new { page = page, total = rowcount, rows = rows };
return Json(result);
like image 200
Matthias Hryniszak Avatar answered Jan 04 '26 09:01

Matthias Hryniszak



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!