I'm experiencing an issue with my grid view where the row colors are not behaving as expected.
https://i.sstatic.net/BzkdH.jpg
When double-clicking on an empty cell in the grid, it should turn green and display "MI". If I double-click on a green cell displaying "MI", it should revert back to its original state with an empty text box and the same background color. However, currently, when clicking on odd row numbers, the color changes to white instead of blue.
This is the code snippet I am working with:
$('#MainContent_GVTest>tbody>tr>td').dblclick(function (e) {
var selTD = $(e.target).closest("td");
var selTR = $(e.target).closest("tr");
if (($.trim($currentCellText) == "MI") && $(selTD).attr('class') == "firsttime") {
selTD.text("");
selTD.addClass("NoClass");
}
}); // This part is functioning as intended
I'm trying to implement logic based on whether the row is even or odd to determine the correct background color. Here's what I've tried so far:
if ($(selTD).is(":even")) {
alert('Even****************');
selTD.addClass("NoClass");
}
if ($(selTD).is(":odd")) {
alert('Odd****************');
selTD.addClass("NoClassOddrow");
}
.NoClass {
background-color: white;
}
.NoClassOddrow {
background-color: blue;
}
After updating the code, I encountered a problem where clicking on the first blue cell alerts "Odd" and turns the cell blue, but clicking on subsequent rows also alerts "Odd" and changes the color to blue again. How can I resolve this issue?