mercredi 4 mai 2016

How to add a checkbox to Kendo UI MVC grid and pass a parameter when button clicked

Sorry if this question has a very simple answer, I'm new in all this thing...

This is my Kendo UI grid with a copyToClipboard button:

@(Html.Kendo().Grid(Model.Where(o => o.TypeID == 1)).Name("Grid").TableHtmlAttributes(new { @class = "grid" })
              .ToolBar(o => o.Template(@<text>
                        <ul class='ul-bulk-menu'>
                            <li><button type="button" id='copyToClip' class='t-button t-button-icon' title='Copy To ClipBoard'></button></li>
                        </ul>
                    </text>))

              .Columns(col =>
              {
                  col.Bound(c => c.AttackID).Hidden().HtmlAttributes(new { id = "attackId" });
                  col.Bound(c => c.WhiteboardId).Hidden().HtmlAttributes(new { @class = "whiteboardid-cell" });
                  col.Bound(c => c.EntityName).Title("Entity");
                  col.Bound(c => c.ElementId).Title("Element");
                  col.Bound(c => c.Url).ClientTemplate(hyperUrl).Title("Domain").Template(o => string.Format("<a href=\"{0}\">{1}</a>", o.Url, o.Domain));
                  col.Bound(c => c.Functionality).Title("Functionality");
                  col.Bound(c => c.shortDurationStatus).Title("Status");
                  col.Bound(c => c.SLHandledBy).Title("Handled By");
                  col.Bound(c => c.DurationInt).Title("Duration");

                  col.Bound(c => c.AttackID).Title("Command").Template(@<text>
                    <button id="@item.AttackID" onclick="assignAnalyst(@item.AttackID, @item.TypeID, this)">Edit</button>
                </text>);

              })
                .Sortable()
                .Groupable()
                .Filterable()
                .Scrollable(o => o.Height(height))
                        .DataSource(dataSource => dataSource.Server().Model(model => model.Id(o => o.AttackID)))
        )

I'm trying to add a checkbox column to my grid. When some rows are checked and the 'copyToClip' button is clicked, I need to pass the 'AttackID' parameter of all checked rows to a function which will copy to clipboard some data from database.

Is it possible?

(Thanks in advance)




Aucun commentaire:

Enregistrer un commentaire