I am wanting to get the data from column 1 on the main grid and the template grid when a checkbox within the template grid is checked.
The grid will hold this type of data. Each row on the main grid will have 4 rows on the template grid. When a checkbox is checked I would like to get the \
data from the main grid row and the template grid row.
Currently I cannot work out what is the main grids row that has been selected and how to get the grid name of the template grid so I can get the data. The JS I have been playing with is below as well. This JS is not what I want but close. I just need to get the info from different grids on selection.
Thanks in advance
function selectColumn(e) {
var grid = $("#siteCriteriaCriteria").data("kendoGrid");
// Get selected rows
var sel = $("input:checked", grid.tbody).closest("tr");
// Get data item for each
var items = [];
$.each (sel, function(idx, row) {
var item = grid.dataItem(row);
var update = item.name;
alert(update);
items.push(item);
});
alert ("selected: " + JSON.stringify(items));
}
@(Html.Kendo().Grid<WebSite.Library.Models.SiteCriteria>()
.Name("siteCriteriaCriteria")
.HtmlAttributes(new { style = "height:60vh; " })
.Scrollable()
.Columns(columns =>
{
columns.Bound(p => p.siteId).Title("siteId").Width(50).Hidden();
columns.Bound(p => p.areaId).Title("AreaId").Width(50).Hidden();
columns.Bound(p => p.name).Title("Hazard Area").Width(150);
columns.Template(p => "").HtmlAttributes(new { @class = "templateCell" }).Title("criteria").Width(200)
.ClientTemplate(
Html.Kendo().Grid<WebSite.Library.Models.SiteCriteria>()
.Name("areaCriteria_#=areaId#")
.Columns(c =>
{
c.Bound(e1 => e1.name).Title("Training").Width(150).HeaderHtmlAttributes(new { style = "display:none;" }).HtmlAttributes(new { style = "height: 15px" });
c.Bound(e1 => e1.areaId).Title("Area").Width(100).Hidden();
c.Bound(e1 => e1.siteCriteria).Title("Access Criteria").ClientTemplate("<input type='checkbox' #=siteCriteria# ' onchange='requestStartHandler(\"grid\");' />")
.HtmlAttributes(new { style = "height: 15px" }).HeaderHtmlAttributes(new { style = "display:none;" });
})
.Events(events => events.DataBound("siteCriteriaCriteria_onDataBound"))
.DataSource(source1 => source1
.Custom()
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/SiteInfo/_getTrainingAreas/_si=" + Model.SiteId)
.DataType("json");
})
))
.ToClientTemplate().ToHtmlString()
);
columns.Command(command => { command.Edit(); }).Width(250);
})
.Events(events => events.Save("onSaveCriteria").DataBound("hideEditCommand"))
.NoRecords("No criteria exists.")
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(source => source
.Custom()
.Schema(schema => schema
.Model(m => m.Id(p => p.siteId)))
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/SiteInfo/_getPremiseArea/_si=" + Model.SiteId)
.DataType("json");
})
))
)