Grid view color change for particular cell

   <script>
  $(document).ready(function(){

         $(this).find("td:eq(0)").addClass('gridcolor');
});
        $("#<%=gvConsCanList.ClientID%> tr").click(function (e) {
            debugger;
            var row = $(e.target).closest("tr");
            //elem = row.children[0];
            //alert(row.children[0]);
            //ele = $(e.target).find('td:first-child').text();
           //alert(ele.text());
            //var cell1 = $(e.target).closest("td").prev("td").text();
            var row = $(e.target).closest("tr");
            var selectedcell = $(e.target).closest("td");
            var cell0 = $(this).find("td:eq(0)");
         
            var cell1= $(this).find("td:eq(1)");
            var cell2 = $(this).find("td:eq(2)");
            var cell3 = $(this).find("td:eq(3)");
            var cell4 = $(this).find("td:eq(4)");
            $(this).find("td:eq(3)").addClass('gridcolor');
            //alert(cell2.text());
            var values = [cell0.text(), cell1.text(), cell2.text(), cell3.text(), cell4.text()];
            for (var i= 0; i <values.length;i++)
            {
                $(this).find("td:eq(0)").removeClass('gridcolor');
                $(this).find("td:eq(1)").removeClass('gridcolor');
                $(this).find("td:eq(2)").removeClass('gridcolor');
                $(this).find("td:eq(3)").removeClass('gridcolor');
                $(this).find("td:eq(4)").removeClass('gridcolor');
                $(this).find("td:eq(5)").removeClass('gridcolor');
                //cell+i.removeClass('gridcolor');
                //alert(values[i]); 
                if (values[i] == selectedcell.text()) {
                   // alert( selectedcell.text());

                 
                    selectedcell.addClass('gridcolor');
                   var a=selectedcell.text();
               $("<%=Label1.ClientID %>").val()=a;
                     //$("#Label1").val("selectedcell.text()");
                }
                else {
                    //alert("helo");
                    selectedcell.addClass('gridcolor');
                    // 


                }
             
             
            }

        });
    </script>





<script>
  function Hovercolor() {
            $('#cphBody_gvconsist td:nth-child(3)').hover(function () {
                $(this).addClass('hjanasena');
            }, function () { $(this).removeClass('hjanasena'); });
            $('#cphBody_gvconsist td:nth-child(4)').hover(function () {
                $(this).addClass('htdp');
            }, function () { $(this).removeClass('htdp'); });
            $('#cphBody_gvconsist td:nth-child(5)').hover(function () {
                $(this).addClass('hysrcp');
            }, function () { $(this).removeClass('hysrcp'); });
            $('#cphBody_gvconsist td:nth-child(6)').hover(function () {
                $(this).addClass('hbjp');
            }, function () { $(this).removeClass('hbjp'); });
        }

        function Changecoloronclick() {
            $('#cphBody_gvconsist td:nth-child(3)').click(function () {
                var tdp = $(this).closest('tr').children('td:eq( 3 )');
                var ysr = $(this).closest('tr').children('td:eq( 4 )');
                var bjp = $(this).closest('tr').children('td:eq( 5 )');
                if (tdp.hasClass('tdp') || ysr.hasClass('ysrcp') || bjp.hasClass('bjp')) {
                    tdp.removeClass('tdp');
                    ysr.removeClass('ysrcp');
                    bjp.removeClass('bjp');
                    $(this).addClass('janasena');
                }
                else {
                    $(this).addClass('janasena');
                }
            });
            $('#cphBody_gvconsist td:nth-child(4)').click(function () {
                var janasena = $(this).closest('tr').children('td:eq( 2 )');
                var ysr = $(this).closest('tr').children('td:eq( 4 )');
                var bjp = $(this).closest('tr').children('td:eq( 5 )');
                if (janasena.hasClass('janasena') || ysr.hasClass('ysrcp') || bjp.hasClass('bjp')) {
                    janasena.removeClass('janasena');
                    ysr.removeClass('ysrcp');
                    bjp.removeClass('bjp');
                    $(this).addClass('tdp');
                }
                else {
                    $(this).addClass('tdp');
                }
            });
            $('#cphBody_gvconsist td:nth-child(5)').click(function () {
                var janasena = $(this).closest('tr').children('td:eq( 2 )');
                var tdp = $(this).closest('tr').children('td:eq( 3 )');
                var bjp = $(this).closest('tr').children('td:eq( 5 )');
                if (janasena.hasClass('janasena') || tdp.hasClass('tdp') || bjp.hasClass('bjp')) {
                    tdp.removeClass('tdp');
                    janasena.removeClass('janasena');
                    bjp.removeClass('bjp');
                    $(this).addClass('ysrcp');
                }
                else {
                    $(this).addClass('ysrcp');
                }

            });
            $('#cphBody_gvconsist td:nth-child(6)').click(function () {
                var janasena = $(this).closest('tr').children('td:eq( 2 )');
                var tdp = $(this).closest('tr').children('td:eq( 3 )');
                var ysr = $(this).closest('tr').children('td:eq( 4 )');
                if (janasena.hasClass('janasena') || tdp.hasClass('tdp') || ysr.hasClass('ysrcp')) {
                    janasena.removeClass('janasena');
                    tdp.removeClass('tdp');
                    ysr.removeClass('ysrcp');
                    $(this).addClass('bjp');
                }
                else {
                    $(this).addClass('bjp');
                }
            });
        }

</script>

Comments

  1. If you are preparing for NEET, you must have acknowledged it is pretty challenging to crack at one go.

    crack neet

    ReplyDelete

Post a Comment

Popular posts from this blog

Automatically send Birthday email using C#.Net

Drag and Drop multiple File upload using jQuery AJAX in ASP.Net using C# and VB.Net

Difference between each and map in jquery