[RESOLVED]Strikeout entire <tr> based on the model field value

Hi,

I am listing db values in an html table . The model contains s filed is_disabled. I need to to display the entire row as strike out if the is_disabled value id true. otherwise noneed to strike out. How can i achieve this using jquery. PLease find my table
below

 <table style=""  id="tblbranchdeatails" class="clsbranchtable">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.BranchName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TourLocation)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.SalesTeam)
            </th>
            
            <th>
                @Html.DisplayNameFor(model => model.SiteID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.IsDisabled)
            </th>
            <th></th>
        </tr>
    
    @foreach (var item in Model) {
        <tr id="tbltr">
            <td  class="tdclass">
                @Html.DisplayFor(modelItem => item.BranchName)
            </td>
            <td  class="tdclass">
                @Html.DisplayFor(modelItem => item.TourLocation)
            </td>
            <td  class="tdclass">
                @Html.DisplayFor(modelItem => item.SalesTeam)
            </td>
            <td  class="tdclass">
                @Html.DisplayFor(modelItem => item.SiteID)
            </td>
            <td  class="tdclass">
               @* @Html.DisplayFor(modelItem => item.IsDisabled)*@
                @(item.IsDisabled?"Yes":"No")
            </td>
            <td class="tdclass">

               @Html.ActionLink("Edit", "Edit", new { branchid = item.BranchID },new { @class = "editDialog"})   
            </td>
                @{  
                    if (item.IsDisabled==true)
                    {
                        <td class="tdclass">              
                        @Html.ActionLink("Enable", "Delete", new { branchid = item.BranchID,enabledisableflag=false }, new { @class = "confirmDialog"})
                        </td>
                    }
                else
                    {
                        <td class="tdclass">
                        @Html.ActionLink("Disable", "Delete", new { branchid = item.BranchID,enabledisableflag=true }, new { @class = "confirmDialogdis"})
                        </td>
                     }
            
                }
      </tr>
    }
    </table> 

Here i am displaying the last td "enable/disable" conditionally. 

If the model.Is_disbaled==true, ineed to strikeout the entire row.

Please help me

Thanks in advance

Vidya

As far as I know, there’s no styling that strikes out the entire row.  The best I could do is strike out just the text of the row.

Here’s how you would do it:

@foreach (var item in Model) {
if (item.IsDisabled == true)
{
<tr id="tbltr" style="text-decoration: line-through">
}
else
{
<tr id="tbltr">
}
..... the rest of your table here ....

Leave a Reply