This is a migrated thread and some comments may be shown as answers.

Conditional CheckBox for Enabling and Disabling

1 Answer 670 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 10 Mar 2015, 01:53 PM
Hi All,
I am stuck with a very small problem. Please help me in solution to the problem.
Basically, I need to compare the value in the BatchingStatus field in my dataset accordingly need to disable the checkbox in the grid.
Following is my code. Attached the screen shot of portal.

@using (Html.BeginForm("ReplaySelectedMessages", "Home"))
   {
        
    <div id="gridContent">
       <h1></h1>  
    @(Html.Kendo().Grid<XYZ.MessageReplay.MvcApp.Models.LogModel>(Model)
    .Name("gridTable") 
   //.EnableCustomBinding(true)
   
    .HtmlAttributes(new {style = "font-family: verdana,arial,sans-serif; font-size: 11px;color: #333333;border-color: #999999;"})       
    .Columns(columns => 
        {
          
            columns.Template(@<text>#if(@item.BatchingStatus) == 0 { # <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' /> #} else {# <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' disabled='disabled'/> #} # </text>).HeaderTemplate(@<text><input class="selectAll" type="checkbox" id="allBox" onclick="toggleSelection()"/></text>).Width(20);
            columns.Bound(p => p.LogID).Template(p => Html.ActionLink(((string)p.LogID), "MessageDetails", new { logid = p.LogID })).Width(200);           
            columns.Bound(p => p.ReceivePortName)
                .Width(100)
                .Filterable(ft => ft.UI("ReceivePortsFilter").Extra(false));          
            columns.Bound(p => p.SendPortName).Width(100).Filterable(ft => ft.UI("SendPortsFilter").Extra(false));
            columns.Bound(p => p.loggedDate).Format("{0:MM/dd/yyyy hh:mm tt}").Filterable(f => f.UI("DateTimeFilter").Extra(true)).Width(100);
            columns.Bound(p => p.ControlID).Width(100).Filterable(e => e.Extra(false));
            columns.Bound(p => p.SenderID).Width(100).Filterable(ft => ft.UI("SenderIDFilter").Extra(false));
            columns.Bound(p => p.ReceiverID).Width(100).Filterable(ft => ft.UI("ReceiverIDFilter").Extra(false));
            columns.Bound(p => p.InterchangeID).Width(100).Filterable(e => e.Extra(false));
            columns.Bound(p => p.ReplayedCount).Width(100).Filterable(e => e.Extra(false));
            columns.Bound(p => p.RetryCount).Width(100).Filterable(e => e.Extra(false));
            columns.Bound(p => p.AckCode).Width(100).Filterable(e => e.Extra(false));
            columns.Bound(p => p.BatchingStatus).Width(100).Filterable(e => e.Extra(false));
        })
           // .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            .Filterable()
            .Pageable(page => page.PageSizes(new int[]{10,25,50,100}).Enabled(true))
            .Sortable()
            .Scrollable(src => src.Height("auto"))
            .Resizable(resize => resize.Columns(true))
            )



1 Answer, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 10 Mar 2015, 02:42 PM

Hi All,

Got it working. Here is the following code.

columns.Template(@<text>@if(((@item.BatchingStatus) == 0)) { <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' /> } else { <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' disabled='disabled'/> }  </text>)
.HeaderTemplate(@<text><input class="selectAll" type="checkbox" id="allBox" onclick="toggleSelection()"/></text>).Width(20);


But I am stuck with the new problem now.
Basically I want add OR condition in my IF Statment. Following the code for the same. 
Somehow the code enables all the checkboxes in the grid and its failing IF condition.

columns.Template(@<text>@if(((@item.BatchingStatus) == 0) || ((@item.AckCode) == "")) { <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' /> } else { <input class='box'  id='assignChkBx' name='assignChkBx' type='checkbox' value='@item.LogID' disabled='disabled'/> }  </text>)
.HeaderTemplate(@<text><input class="selectAll" type="checkbox" id="allBox" onclick="toggleSelection()"/></text>).Width(20);

Cheers
Dino

Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Share this question
or