Advanced ASP.NET Gridview Layout
- by chief7
So i had a feature request to add fields to a second table row for a single data row on a GridView. At first, I looked at extending the functionality of the GridView but soon realized this would be a huge task and since I consider this request a shim for a larger future feature decided against it. Also want to move to MVC in the near future and this would be throw away code.
So instead I created a little jquery script to move the cell to the next row in the table.
$(document).ready(function() {
$(".fieldAttributesNextRow").each(function() {
var parent = $(this).parent();
var newRow = $("<tr></tr>");
newRow.attr("class", $(parent).attr("class"));
var headerRow = $(parent).parent().find(":first");
var cellCount = headerRow.children().length - headerRow.children().find(".hide").length;
newRow.append($(this).attr("colspan", cellCount));
$(parent).after(newRow);
})
});
What do you think of this? Is this a poor design decision? I am actually quite pleased with the ease of this solution. Please provide your thoughts.