Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6759649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:58:15+00:00 2026-05-26T13:58:15+00:00

I am using a WebGrid to display a List of Items, some items in

  • 0

I am using a WebGrid to display a List of Items, some items in the list are disabled, so I would like to make it dimmed in the grid, to do that I must set the row class to be dimmed if the item is disabled, I do not know how to set the row class according to a condition

This is my sample code

  var grid = new WebGrid(Model, canPage: true, rowsPerPage: 20);
                @grid.GetHtml(tableStyle: "grid",
                                rowStyle: "gridrow",
                                alternatingRowStyle: "gridrow_alternate",
                                mode: WebGridPagerModes.All,
                                numericLinksCount: 10,
                                columns: grid.Columns(
                                    grid.Column("Name", "Name", item => (item.LocationData[0].Name), canSort: true, style: "width:60%"),
                                    grid.Column("Url", "Url", canSort: true, style: "width:60%"),
                                    grid.Column("Edit", "", @<a href='../VenHome/Edit/@item.ID' ><img src='/content/icons/edit.png'
                                        alt='Edit' />
                                    </a>, style: "width:150px"),
                                    grid.Column("Delete", "", @<a href='#' id='Delete' itemId='@item.ID' title='@item.LocationData[0].Name'><img
                                        src='/content/icons/delete.png' alt='Delete' />
                                    </a>, style: "width:150px"),
                                    grid.Column("Details", "", @<a href="../VenHome/Details/@item.Id" title="Details">
                                        <img src="../../Content/Icons/Details.png" alt="Details" /></a>)
                                    ));

            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:58:16+00:00Added an answer on May 26, 2026 at 1:58 pm

    I found a solution for this problem using JQuery, I added a CSS class attribute for a grid column inner HTML
    This is the previous Code with added attribute


     @{
            var grid = new WebGrid(Model, canPage: true, rowsPerPage: 20);
                    @grid.GetHtml(tableStyle: "grid",
                                    rowStyle: "gridrow",
                                    alternatingRowStyle: "gridrow_alternate",
                                    mode: WebGridPagerModes.All,
                                    numericLinksCount: 10,
                                    columns: grid.Columns(
                                        grid.Column("Name", "Name", item => (item.LocationData[0].Name), canSort: true, style: "width:60%"),
                                        grid.Column("Url", "Url", canSort: false, style: "width:60%"),
                                        grid.Column("Edit", "", @<a href='../VenHome/Edit/@item.ID' ><img src='/content/icons/edit.png' alt='Edit' /></a>, style: "width:150px"),
                                        grid.Column("Delete", "", @<a href='#' id='Delete' class="temp" removed="@item.Removed" itemId='@item.ID' title='@item.LocationData[0].Name'><img src='/content/icons/delete.png' alt='Delete'  /></a>, style: "width:150px"),
                                        grid.Column("Details", "", @<a href="../VenHome/Details/@item.Id" title="Details">
                                            <img src="../../Content/Icons/Details.png" alt="Details" /></a>)
                                        ));
    
                }
    

    This is the code modified

      grid.Column("Delete", "", @<a href='#' id='Delete' class="temp" removed="@item.Removed" itemId='@item.ID' title='@item.LocationData[0].Name'><img src='/content/icons/delete.png' alt='Delete'  /></a>, style: "width:150px"),
    

    I added a class “temp” to the delete link and also add an attribute “removed” has the condition value, and I added the following JQuery code

     $(".temp").each(function (index, element) {
                if (($(element).attr("removed")) == "False") {
                    $(element).parent().parent().attr("class", "deleted");
    
                    $(element).find("img").attr("src", "../../content/icons/deleted.png");
                }
            });
    

    Note: if the item is removed then displays the row as dimmed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC3 and displaying my data in a webgrid. I would like
I am using a webGrid and would like to be able to change the
I am using a webgrid to display some dynamic data. I have recently refactored
Using Rails 3.2.0 with haml and sass: I Would like to link an external
I'm using MVC3 webgrid to display, sort and paginate data. The display is fine,
I'm new to MVC so have some conceptual issues. I have a WebGrid that
I'm using MVC3 and webgrid on a system. I like to know if it's
I am using this webgrid in my view. <div class=grid> @{ var grid =
I am trying to use a WebGrid to display some data, this is fine
I'm unexperienced with Ajax. I'm using a webgrid that executes: javascript:__doPostBack('GridView1','Select$1') when a row

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.