mercredi 1 juin 2016

Retrieve value from row with checkbox checked

What I am trying to do

A bit of context, We have an application and on the index page we simply list items from the DB. What we are trying to do is, when we select the checkbox(max 10) to the left of the index record, we pass the ID to another page so we can essentially show 5 images of the selected records.

What we have done

What we have done so far is simple add a checkbox to our gridmvc.

Problem

The problem we are experiencing is, that we are not entirely sure of

A ) How to limit the selection to 10.

B) How to pass the value we need from the selected row to a function, or a controller. Basically, we have no idea how to retrieve it.

PS passing it to function or controller doesnt matter, would just like to know how to access it. I should also mention I am using GRID MVC for my grid

@using stuRegister.Helper
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using GridMvc.Html

@model List<stuRegister.Models.tbl_out_stu>

<h2>Mass Print Images</h2>
<h4>Select a maximum of 10 students to print corresponding label</h4>

 @Html.NoEncodeActionLink("Print Selected", "Add New", "Create", "Outgoing", routeValues: null, htmlAttributes: new { @onclick="loadCC()",@class = "btn btn-primary" })

<input type="button" value="Print Selected" id="btnManMail" class="btn btn-primary" onclick="loadCC()" />


@Html.Grid(Model).Columns(columns =>
{
    columns.Add().Titled("Print Multiple Images").Encoded(false).Sanitized(false).SetWidth(30).RenderValueAs(o => Html.CheckBox("massPrint", false));
    columns.Add(data => data.in_refno).Titled("Reference No.");
    columns.Add(data => data.destination).Titled("Orgin");
      columns.Add(data => data.date_sent).Titled("Date Sent").Format("{0:MMM-dd-yyyy}");

    }).Sortable(true).WithPaging(20).Filterable(true)

<input type="button" value="Print Selected" id="btnManMail" class="btn btn-primary" onclick="loadCC()" />




Aucun commentaire:

Enregistrer un commentaire