I am not an expert in JQuery But I have this code that sets the header fixed and it works as intended:
$(document).ready(function () {
fixedHeader()
});
function fixedHeader() {
// Code to copy the gridview header with style
var gridHeader = $('#<%=GridView1.ClientID%>').clone(false);
//Code to remove all rows except the header row
$(gridHeader).find("tr:gt(0)").remove();
$('#<%=GridView1.ClientID%> tr th').each(function (i) {
// Here Set Width of each th from gridview to new table th
$("th:nth-child(" + (i + 1) + ")", gridHeader).css('width', ($(this).width()).toString() + "px");
});
// Append Header to the div controlHead
$("#controlHead").append(gridHeader);
// Set its position to be fixed
$('#controlHead').css('position', 'fixed');
// Put it on top
$('#controlHead').css('top', $('#<%=GridView1.ClientID%>').offset().top);
}
The problem is I lose functionality like this button doesn't call the JS anymore
<asp:Button ID="BtnDelete" runat="server" Text="Delete" onclick="btnDelete_Click" class="buttons" Visible="true" disabled="disabled" OnClientClick="if (!deleteRow()) return false;" />
and I had this function that would highlight the selected row when radio button is selected
// Method that will highlight row
function gridviewManipulation() {
// Get Gridview
var gridView = document.getElementById("<%= GridView1.ClientID %>");
// Loop through the Gridview
for (var i = 1; i < gridView.rows.length; i++) {
// Get the radio button of each row in the gridview and see if its checked
if (gridView.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked == true)
{
// Place the color for selection
gridView.rows[i].style.background = '#9bc27e';
}
else if (gridView.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked == false && i % 2 == 0)
{
// If its even then place white color back
gridView.rows[i].style.background = '#FFFFFF';
}
else
{
// If its odd place the bluish back on
gridView.rows[i].style.background = '#E3EAEB';
}
}
}
Is there another way to get the header fixed with JQuery? I think the clone and the appending of the new cloned header is ripping my functionality, Any help would be very appreciated!