"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, January 16, 2013

Add text N\A on empty gridview cell in jquery

 Add alternate text on empty grid-view cell in jquery




$(document).ready(function () {
            $("#GridViewID td").each(function () {
                var cellText = $(this).text();
                if ($.trim(cellText) == '') {
                    $(this).text('N/A');
                }
            });
        });

 if ur having edit option rearrange ur code like below

$("#<%= this.gvClientDetails.ClientID %> tr").each(function() {
                if ($(this).find('td:eq(9)').text().trim() == "Edit") {
                    $(this).find('td').each(function() {
                        var cellText = $(this).text().trim();
                        if (cellText == '') {
                            $(this).text('N/A');
                        }
                        else {
                        }
                    });
                }
            });

Output



sometimes i may feel ,i traveled a lot but now i feel i didn't moved an inch ... jquery rockz...

If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: