ASP.NET MVC 3 WebGrid Sort Order Image -
i working webgrid, , have image or character "^" "v" in header showing column sort order.
how can this?
this code of 1 of webgrids:
<div id="contenedor-gridactividad"> @{ webgrid gridactividad = new webgrid(model.actividaddiaria, ajaxupdatecontainerid: "contenedor-gridactividad", rowsperpage: 20); } @gridactividad.gethtml( fillemptyrows: true, alternatingrowstyle: "fila-alternativa", headerstyle: "encabezado-grid", footerstyle: "pie-grid", mode: webgridpagermodes.all, firsttext: "<<", previoustext: "<", nexttext: ">", lasttext: ">>", columns: new[] { gridactividad.column("contrato", header: "contrato"), gridactividad.column("observacion", header: "observación"), gridactividad.column("descr", header: "tarea"), gridactividad.column("fecha", header: "fecha", format: (item) => { return item.fecha.tostring("dd/mm/yyyy"); } ), gridactividad.column("", header: "estado", format: (item) => { if (item.estado == "vc") { return html.image("/imagenes/vc.gif","validado correcto", new { @border = "0"}); } else if (item.estado == "vi") { return html.image("/imagenes/vi.gif", "validado incorrecto", new { @border = "0" }); } else if (item.estado == "nv") { return html.image("/imagenes/vp.gif", "no validado", new { @border = "0" }); } else { return html.image("/imagenes/nv.png", "pendiente validar", new { @border = "0" }); } } ), gridactividad.column("jdp", header: "jdp") } ) </div>
i did google search on "webgrid sort indicator" , came result http://prokofyev.blogspot.com/2011/01/sort-indicator-in-systemwebhelperswebgr.html
basically, person uses jquery add in sort direction image.
<script type="text/javascript"> $('thead > tr > th > a[href*="sort=@grid.sortcolumn"]').parent() .append('@(grid.sortdirection == sortdirection.ascending ? "u" : "d")'); </script>
(as added bonus, tested myself, can copy , paste code (the link 1 picture instead of code sample :( ...) replace u , d whatever want display instead.
hope helps.
Comments
Post a Comment