dataSource = new kendo.data.DataSource({
transport: {
read: {
url: URL,
dataType: "jsonp"
},
update: {
url: "",
dataType: "jsonp"
},
destroy: {
url: "",
dataType: "jsonp"
},
create: {
url: "",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 10,
schema: {
model: {
id: "PROJECT_ID",
fields: {
"PROJECT_ID": { editable: false, nullable: true },
"PROJECT_NM": { validation: { required: true} },
"PROJECT_DESC": { validation: { required: true} },
"ACTIVE_IND": { type: "boolean" }
}
}
}
});
//GRID
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 400,
toolbar: ["create"],
columns: [
{ field: "PROJECT_ID", title: "ID" },
{ field: "PROJECT_NM", title: "Name" },
{ field: "PROJECT_DESC", title: "Description" },
{ field: "ACTIVE_IND", title: "Active" },
{ command: ["edit"], title: " "}],
editable: "popup",
save: function (e) {
var g = $("#grid").data("kendoGrid");
var ds = g.dataSource;
var refresh = false;
//alert(kendo.stringify(e.model));
var url = "";
e.model.ACTIVE_IND = e.model.ACTIVE_IND ? 1 : 0
$.ajax({
url: url,
data: kendo.stringify(e.model),
type: 'POST',
processData: true,
async: false,
contentType: "application/json",
success: function (data, textStatus, jqXHR) {
alert("Updated")
},
error: function (xhr, status, error) {
alert("Failed to Update");
}
});
}
});
$(
"#cmbCompany"
).width(350).kendoComboBox({
placeholder:
"Select company"
,
serverFiltering:
true
,
dataTextField:
"Company"
,
dataValueField:
"ClientNo"
,
dataSource: {
transport: {
read:
"/Admin/GetAllCompany"
}
},
change:
function
() {
var
value =
this
.value();
if
(value) {
employeeDataSource.query({ companyNo: value });
employee.enable();
}
else
{
employee.enable(
false
);
}
employee.value(
""
);
}
});
var
employeeDataSource =
new
kendo.data.DataSource({
transport: {
dataType:
"json"
,
read:
"/Admin/GetEmployeesByCompany"
}
});
var
employee = $(
"#cmbEmployee"
).width(300).kendoComboBox({
autoBind:
false
,
placeholder:
"Select employee"
,
dataTextField:
"Name"
,
dataValueField:
"Email"
,
dataSource: employeeDataSource
}).data(
"kendoComboBox"
);
columns: [
{ field: "FirstName", title: "productos", format: "{0:c}", type:"String",editable: false, width: "150px" },
{ field: "City", title: "cantidad", editable:true, type:"Number", validation: { min: 1, required: true },width: "150px" },
{field: "BirthDate", title: "fecha de Entrega",type:"String",editable:true,width:"150px"},
{ field: "favoritos", title: "favoritos", editable:true, type:"String",width: "150px" },
{field: "boton", template: "#= '<
form
id=\"form3\" method=\"post\" action=\"prueba9.asp\"><
input
type=\"text\" name=\"nombre\"id=\"<-------------------here\"><
input
type=\"text\" name=\"apellido\" id=\"<------------------here\"><
input
type=\"button\" id=\"boton3\"class=\"boton3\"value=\"Enviar\" onclick=\"
document.form3.nomb.value
=documen t.form3.nomb.value;
document.form3.favo.value
=document.form3.favo.value;submit();\"></
form
>' #", title: "favorito", width: "100px",type:"String", editable:false },
{ field: "añadir", template: "#= '<
input
type
=
IMAGE
SRC=\"add.gif\"\id=\"añadir\" value=\"CODE\" />' #", title: "añadir", width: "210px",type:"String", editable:false }],
<
div
data-role
=
"rangeslider"
data-bind
=
"value: Capacity, events: {change: editCapacity}"
data-max
=
"20"
>
<
input
/>
<
input
/>
</
div
>
//From the model
editCapacity:
function
(site) {
saveCapacity(site);
}
function
saveCapacity(site){
var
data =
{
"id"
: viewModel.BlockID ,
"campusid"
: viewModel.selectedCampus.get(
"CampusID"
),
"rotationid"
: viewModel.selectedRotation.get(
"RotationID"
),
"siteid"
: site.data.get(
"SiteID"
),
"min"
: site.data.get(
"Capacity"
)[0],
"max"
: site.data.get(
"Capacity"
)[1]
};
$.ajax({
url:
"/api/cps/clerkship/blocks/"
+ viewModel.BlockID +
"/editcapacity"
,
type:
"PUT"
,
data: data,
}).done(
function
() {
});
}
viewModel = kendo.observable({
selectedItem:
null
,
editItem:
function
(item) {
selectedItem = item;
}
});