Advanced ASP.NET Gridview Layout

Posted by chief7 on Stack Overflow See other posts from Stack Overflow or by chief7
Published on 2009-03-03T21:46:28Z Indexed on 2010/06/17 3:03 UTC
Read the original article Hit count: 291

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery