Flexigrid - adding a column with links

Matthias Hryniszak picture Matthias Hryniszak · May 31, 2009 · Viewed 7.3k times · Source

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?

Answer

Matthias Hryniszak picture Matthias Hryniszak · May 31, 2009

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);