or
function instantBoolEditor(container, options) { // flip value options.model.set('enabled', !options.model.enabled); // replace html with the same template the column uses [...] // should I do something like trigger change? options.model.trigger("change", {container: container, model:options.model}); }The container in which the editor must be added.
Additional options.
The field for the editor.
The toolbar in the details grid will not open a "popup" or "inline" when I click the create function. The "save", "cancel", "delete" all work. Am I missing something? Also, the "create" in the main grid works just fine.
var sigSource = new kendo.data.DataSource({
transport: {
read: {
url: "signatures/sigrequests_json_output",
dataType: "json"
},
create: {
url: "signatures/Create",
dataType: "json"
}
},
schema: {
data: "results",
total: "count",
model: {
id: "sigreq",
fields: {
ticket_uid: { editable: false },
name: { type: "string", validation: { required:true } },
description: { type: "string" },
assigned_to: { editable: false, defaultValue: return_user() },
current_status: { editable: true },
priority: { editable: true },
ticket_tlp: { editable: true },
ticket_type: { editable: true },
discovery: { editable: true },
rule_type: { editable: true },
rule_category: { editable: true },
parent_template: { editable: true },
reference: { editable: true },
date_created: { editable: false }
}
}
},
batch: false,
pageSize: 100,
serverPaging: true,
serverFiltering: true,
serverSorting: true
});
$("#kendosigsrequests").kendoGrid({
dataSource: sigSource,
filterable: true,
sortable: true,
scrollable: true,
reorderable: true,
columnMenu: true,
height: 600,
toolbar: [ { name: "create", text: "Create New Request" } ],
pageable: {
refresh: true,
pageSizes: [10, 20, 50, 100, 150, 200, 300]
},
detailInit: detailInit,
dataBound: function() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
},
columns: [
{ field : "name", title : "Name", width : 200 },
{ field : "description", title : "Description", width : 200 },
{ field : "assigned_to", title : "Assigned To", width : 200 },
{ field : "current_status", title : "Current Status", width : 150, editor: stautsDropDownEditor },
{ field : "priority", title : "Priority", width : 90, editor: priorityDropDownEditor },
{ field : "ticket_tlp", title : "TLP", width : 90, editor: tickettlpDropDownEditor },
{ field : "ticket_type", title : "Type", width : 90, editor: tickettypeDropDownEditor},
{ field : "discovery", title : "Discovery", width : 100, editor: discoveryDropDownEditor },
{ field : "rule_type", title : "Rule Type", width : 100, editor: ruletypeDropDownEditor },
{ field : "rule_category", title : "Rule Category", width : 100 },
{ field : "parent_template", title : "Parent Template", width : 300, editor: categoryDropDownEditor },
{ field : "reference", title : "Reference" },
],
editable: "popup"
});
/////////////////////////////////////////
function detailInit(e) {
var detailRow = e.detailRow;
var commentSource = new kendo.data.DataSource({
transport: {
read: {
url: "signatures/Comments",
dataType: "json"
},
create: {
url: "signatures/NewComment",
dataType: "json"
},
update: {
url: "signatures/UpdateComment",
dataType: "json"
}
},
batch: true,
pageSize: 6,
schema: {
data: "comments",
model: {
id: "comment",
fields: {
ticket_uid: { editable: true },
user: { editable: true },
comment: { editable: true },
date_created: { editable: true }
}
}
},
filter: { field: "ticket_uid", value: e.data.ticket_uid }
});
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: commentSource,
toolbar: ["create"],
pageable: true,
editable: "inline",
columns: [
{ field: "date_created", title: "Date", width: 150 },
{ field: "user", title: "By", width: 100 },
{ field: "comment", title: "Comment" },
{ command: "edit" }
]
});
}
var grid = $("#GridField").kendoGrid();function grid_selected(e) { var id; grid.select().each(function() { // CRASH HERE.. Doesent get a dataitem.
var dataItem = grid.dataItem($(this)); id = dataItem.SalonID; }) window.location.href = "@Url.Action("Details", "Salon")" + "/" + id;}<p>@(Html.Kendo().AutoComplete() .Name("searchField") .DataTextField("SalonName") .Filter("Contains") .Placeholder("Search..") .DataSource(dataSource => { dataSource.Read(read => { read.Action("GetAutoCompleteItems", "Salon"); }) .ServerFiltering(false); }) .Events(events => events.Change("autoComplete_selected")) ) </p> <div id="Grid">@(Html.Kendo().Grid(Model) .Name("GridField") .Columns(columns => { columns.Bound(item => item.SalonID); columns.Bound(item => item.Avtnr); columns.Bound(item => item.SalonName); columns.Bound(item => item.Street); columns.Bound(item => item.ZipCode); columns.Bound(item => item.City); columns.Bound(item => item.Telephone); columns.Bound(item => item.SalonEmail); columns.Bound(item => item.Description); columns.Bound(item => item.ContactPerson); }) .ColumnMenu() .Groupable() .Pageable() .Sortable() .Resizable(resize => resize.Columns(true)) .Selectable(selectable => selectable.Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Read", "Salon")) .ServerOperation(false) ) .Events(events => events.Change("grid_selected")))</div><script type="text/javascript">var grid = $("#GridField").kendoGrid();function grid_selected(e) { var id; grid.select().each(function() { var dataItem = grid.dataItem($(this));
// CRASH HERE.. Doesent get a dataitem.
id = dataItem.SalonID;
}) window.location.href = "@Url.Action("Details", "Salon")" + "/" + id;}// // Filter the grid when searching..// function autoComplete_selected(e) { var value = this.value(); if (value) { grid.data("kendoGrid").dataSource.filter({ field: "SalonName", operator: "contains", value: value }); } else { grid.data("kendoGrid").dataSource.filter({}); }}</script>