How can I activate or deactivate users in kendo grid using check boxes?

2 posts, 0 answers
  1. Steven
    Steven avatar
    1 posts
    Member since:
    Jun 2008

    Posted 05 Aug 2014 Link to this post

    @using (Html.BeginForm("Update", "MyUsers", FormMethod.Post))
    {

    @(Html.Kendo().Grid(Model).Name("Usersgrid").Columns(col =>
    {
    col.Bound(i => i.Id).Hidden();
    col.Bound(b => b.Email);

    col.Bound(p => p.UserActive).ClientTemplate("<input type='checkbox'
    name='checkedvalues' class='chkbx'
    value='#= Id #' " + "# if (UserActive)
    { #" + "checked='checked'" + "# } #" + "/>" +

    " <input type=\"hidden\" name=\"checkedvals\"
    value=\"#=Id#\"/>")
    .HeaderTemplate("<input type='checkbox' id='checkAll' /><label
    for='checkAll'>Select </label>").Width(120);

    col.Command(c => c.Custom("Remove").Click("remove")).Width(120);

    }).DataSource(d => d.Ajax()
    .Model(m => m.Id("Id"))
    .Read(p => p.Url("/Customers/GetCustomerIndex").Type(HttpVerbs.Get)))

    )
    <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
    <input type="submit" value="Save Users" class="btn btn-default" id="btnGroupInv2" style="color: rgb(8, 4, 36)" />
    </div>
    </div>
    }
     I have "SelectAll" header template for checking and unchecking for all check boxes.I am unable to post the unchecked values with id's on clicking submit button ?I spent many hours on this. Any Suggestions  or any other methods would be grateful thanks

  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 07 Aug 2014 Link to this post

    Hello Steven,

    Only checked items are submit to the server. 

    http://stackoverflow.com/questions/11424037/does-input-type-checkbox-only-post-data-if-its-checked

    Consider using a hidden input. Similar approach is used in this code library:

    http://www.telerik.com/support/code-library/submit-form-containing-grid-along-with-other-input-elements

    Kind Regards,
    Petur Subev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top