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

Grid "selected" checkboxes

1 Answer 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 28 Oct 2013, 01:23 AM
MVC, Razr

I've got a model Event.  Event has children Participants.  

On the detail page for Event I am trying to display a list of participants for the currently viewed event and give the user the option to select participants.  

 I can't figure out how to display the participants for the currently selected Event using JSON bound grid.  I did manage to get this working with the events on the index page (selectable events, checkboxes etc), but I can't figure out how to create a JSON request to the controller for the participants for the currently selected Event.  

I did have better luck with binding to the view model (below), but I can't get my checkboxes to display (first column) and even if I get them displaying, I'm not really sure I want to loop through the rows with jscript and process each checked row. 

Thanks in advance

michael

<code>
====== Controller ========
        public ActionResult Details(int id = 0)
        {
            Event evt= db.EventFind(id);
            if (deform == null)
            {
                return HttpNotFound();
            }
            return View(evt);
        }

====== View ========
@model Application.Models.Event
...
@(Html.Kendo().Grid(Model.Participants).Name("participantsGrid")
      .Columns(c =>
          {
              c.Template(@<text></text>).ClientTemplate("<input type='checkbox' #= ApprovedFlag ? checked='checked':'' # class='chkbx' />")
             .HeaderTemplate("<p>Org Approved</p>");
             c.Bound(p => p.FullName).ClientTemplate(@Html.ActionLink("#=FullName#", "Details", new { Id = "#=ParticipantId#" }).ToHtmlString());
             c.Bound(p => p.ParticipantId);
              c.Bound(p => p.OrgApprovedFlag);
          })
            .DataSource(ds => ds
                   .Server()
                    .Model(model =>
                    {
                        model.Id(p => p.ParticipantId);
                    })
            .Read(read => read.Action("GetParticipants", "Event"))
            )
          )
</code>

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 29 Oct 2013, 12:31 PM
Hello Michael,

I am not sure I understand your question. Do you use grid hierarchy like the one shared here?

http://demos.kendoui.com/web/grid/hierarchy.html

If you do, then you will need to escape the client expressions used within the inner Grid with slashes (you shuold escape the slash symbols)

e.g.

#= #
 
should become
 
\\#= \\#

If this is not what you mean, can you please elaborate on the issue?

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!
Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or