or
/// <summary>/// /// </summary>public class NotificacionController : Controller{ /// <summary> /// /// </summary> /// <returns></returns> public ActionResult Index() { return View(CargarEmpleados()); } /// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public ActionResult CargaEmpleados([DataSourceRequest] DataSourceRequest request) { return Json(CargarEmpleados().ToDataSourceResult(request), JsonRequestBehavior.AllowGet); } /// <summary> /// /// </summary> /// <returns></returns> private static IEnumerable<EmpleadoModel> CargarEmpleados() { return EmpleadosGateway.ObtenerEmpleados(); }}@(Html.Kendo().Grid<Sic.Mvc.Eventos.Models.Base.EmpleadoModel>() .Name("Grid") .Columns(columns => { columns.Bound(e => e.NombreCompleto).Groupable(false).Width(140); columns.Bound(e => e.Email); }) .Pageable() .Sortable() .Scrollable() .Filterable() .Groupable() .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("CargaEmpleados", "Notificacion")) ))<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/kendo.common.min.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Content/kendo.default.min.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Content/kendo.dataviz.min.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Content/Header.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Content/Footer.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Content/Site.css")" rel="Stylesheet" /> <link href="@Url.Content("~/Scripts/jquery.min.js")" /> <link href="@Url.Content("~/Scripts/kendo.all.min.js")" /> <!-- Usaremos kendo.all.min.js para disponer de Kendo UI y DataViz --> <link href="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")" /> </head> <body> <div id="Contenedor"> <div id="header"> @{Html.RenderPartial("_Panel");} @{Html.RenderPartial("_Reloj");} </div> <div id="section"> @RenderBody() </div> <div id="footer"> <img src="@Url.Content("~/Content/Images/HTML5.png")" alt="HTML5 compatible" /> </div> </div> </body></html>$("#history_grid").kendoGrid({columns: [{ field: "type", title: "Document Type" },{ field: "entity", title: "To/From" },{ field: "date_received", title: "Date Sent/Received" },{ field: "path", title: " ", template: '<a href="${ path }">Link to file</a>', width: "80px" },{ command: { name: "ViewFile", text: "ViewFile", click: viewDoc }, title: " ", width: "100px" }],scrollable: true,autobind: false,dataSource: history_datasource});function viewDoc(e) {e.preventDefault();alert("Hello, world!");};
$(function() {
kendo.culture("es-ES");
var grid = $("#grid").kendoGrid({dataSource: {transport: {read: "datos_grid.php",create: {url: "datos_grid.php",type: "POST"},parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)}
}
}},schema: {data: "data",total: function(result) {
var data = this.data(result);
return data ? data.length : 0
},model: {id: "id",fields: {id: {validation: {required: true}},user_id: {validation: {required: true}},purchase_date: {validation: {required: true},type: "date"}}}},pageSize: 5,autoSync: true,batch: true},columns: [{title: "ID",field: "id",type: "text"}, {title: "Id Usuario",field: "user_id",type: "text"}, {title: "Fecha",field: "purchase_date",format: "{0:dd/MM/yyyy}"}, {command: ["edit", "destroy"],title: " ",width: "210px"}],pageable: {refresh: true,pageSizes: 5},toolbar: ["create", {template: kendo.template($("#template").html())}],editable: "inline"});
$("#category").keyup(function() {
var value = $(this).val();
if (value) {
grid.data("kendoGrid").dataSource.filter({logic: "or",filters: [{field: "id",operator: "contains",value: value}, {field: "user_id",operator: "contains",value: value}]})
} else {
grid.data("kendoGrid").dataSource.filter({})
}
})
});
grid.kendoGrid({ dataSource: { transport: { read: function(options) { options.success(filters); // filters is the local array of data }, create: function(options) { prime.dsCrud({ url: 'CreateFilters', crud: options }); }, update: function (options) { prime.dsCrud({ url: 'UpdateFilters', crud: options }); }, destroy: function(options) { prime.dsCrud({ url: 'DestroyFilters', crud: options }); }, parameterMap: function(options, operation) { console.log(operation); // *** never fires! *** } }, batch: true, pageSize: 10, schema: { model: { id: 'id', fields: { id: { editable: false, nullable: true }, member: { type: 'string', validation: { required: true } }, operator: { type: 'number', validation: { required: true } }, dataType: { type: 'string', validation: { required: true } }, value: { type: 'string', validation: { required: true } } } } } }, sortable: true, pageable: true, filterable: false, editable: true, navigatable: true, toolbar: ["create", "save", "cancel"], columns: [ { field: 'member', title: 'Column' }, { field: 'operator', title: 'Operator' }, { field: 'value', title: 'Value(s)' }, { command: 'destroy', title: '', width: '170px' } ]});prime.dsCrud = function (options) { $.ajax({ url: prime.data.queryTool + options.url, dataType: 'jsonp', contentType: 'application/json', type: 'POST', data: options.crud.data, success: function(data, textStatus, jqXHR) { options.crud.success(data); }, error: function(jqXHR, textStatus, errorThrown) { options.crud.error(jqXHR); }, complete: function(jqXHR, textStatus) { console.log('-----------------------------------'); console.log('response from ' + options.url + ':'); console.log(jqXHR); console.log('-----------------------------------'); } });}