or
$(#treview) .removeClass('k-treeview') .empty();$(#treeview).kendoTreeView({ dataSource: getNewdata(), select: onNodeSelect});<script type="text/javascript" language="javascript"> $(document).ready(function () { $("#grid").kendoGrid( { groupable: true, scrollable: true, sortable: true, pageable: true, filterable: true, dataSource: { type: "json", transport: { read: { url: "/Item/GetItems", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8" } } }, columns: [ { field: "ID", title: "ID" }, { field: "InvNo", title: "Инв.номер" } ] }); }); </script>public JsonResult GetItems() { List<SelectListItem> searchParams = new List<SelectListItem>(); searchParams.Add(new SelectListItem() { Value = "InvNo", Text = "121" }); IList<Item> data = _itemService.GetItems(searchParams); return Json(data.ToList(), JsonRequestBehavior.AllowGet); }
$('#grid').kendoGrid({ height: 520, sortable: true, pageable: true, groupable: true, dataSource: new kendo.data.DataSource({ serverPaging: true, serverSorting: false, pageSize: RecebimentoAutomatico.Configuracoes.RegistrosPorPagina, transport: { read: { url: function () { return UrlComParametros() }, contentType: 'application/json; charset=utf-8' } }, schema: { data: 'dados', total: 'total' } }), columns: [ { field: 'IdentificadorProcessamento', title: ' ', template: '<input type="checkbox" value="#=IdentificadorProcessamento#">', width: 30, sortable: false }, { field: 'NumeroNota', title: 'N° da Nota', width: 60 }, { field: 'DataEmissao', title: 'Data Emissão', width: 100 }, { field: 'DataEntrada', title: 'Data Entrada', width: 95 }, { field: 'NomeFornecedor', title: 'Parceiro', width: 300, template: '<span rel="tooltip" title="#=NomeFornecedor#">#=NomeFornecedor#</span>' }, { field: 'EstruturaValida', title: 'Consulta NFe Nacional', width: 100, template: '<div style="text-align: center;"><i class="icon-24 icon-efisc-restricted"></i></div>' }, { field: 'EstruturaValida', title: 'Integridade do XML', width: 100, template: '<div style="text-align: center;"><i class="icon-24 # if(EstruturaValida == true) { #icon-efisc-check#}else{#icon-efisc-error#}#"></i> <a href="#=UrlDetalhesValidacao#" title="Ver detalhes da validação" href=""><i class="icon-24 icon-efisc-lupa"></i></a></div>' }, { field: 'ValidaNaSefaz', title: 'Válido na Sefaz', width: 100, template: '<div style="text-align: center;"><i class="icon-24 # if(ValidaNaSefaz == true) { #icon-efisc-check#}else{#icon-efisc-error#}#"></i> <a href="#=UrlDetalhesValidacao#" title="Ver detalhes da validação" href=""><i class="icon-24 icon-efisc-lupa"></i></a></div>' }, { field: 'ValidaNoSystax', title: 'Válido no Systax', width: 100, template: '<div style="text-align: center;"><i class="icon-24 # if(ValidaNoSystax == true) { #icon-efisc-check#}else{#icon-efisc-error#}#"></i> <a href="#=UrlDetalhesSystax#" title="Ver detalhes da validação" href=""><i class="icon-24 icon-efisc-systax"></i></a></div>' }, { field: 'ValidaNoValidate', title: 'Válido no Validate', width: 105, template: '<div style="text-align: center;"><i class="icon-24 # if(ValidaNoValidate == true) { #icon-efisc-check#}else{#icon-efisc-error#}#"></i> <a href="#=UrlDetalhesValidateReceita#" target="_blank" title="Ver detalhes da RFB" href=""><i class="icon-24 icon-efisc-rfb"></i></a><a href="#=UrlDetalhesValidateSintegra#" target="_blank" title="Ver detalhes do Sintegra" href=""><i class="icon-24 icon-efisc-sintegra"></i></a></div>' }, { field: 'ChaveNFe', title: 'Integração', width: 180, template: sapTemplate }, { field: 'UrlVisualizar', title: 'NFe', width: 50, template: '<a href="#=UrlVisualizar#" title="Visualizar Nota Fiscal Eletrônica"><i class="icon-24 icon-efisc-lupa"></i></a><a href="#=UrlVisualizarImpressao#" title="Visualizar Nota Fiscal Eletrônica para Impressão"><i class="icon-24 icon-efisc-printer"></i></a>' }, { command: { text: "Details", className: "details-button" }, title: " ", width: "110px" } ], dataBound: function () { if (this.dataSource.group().length == 0) { setTimeout(function () { $(".k-grouping-header").html("Arraste uma coluna aqui para agrupar"); }); } //Inicia tooltips $('#grid span').tooltip(); MostraTotal(); }});@using (Html.BeginForm("Index", "CodeManager")){ <p> <label for="startsWith"> <strong>Category:</strong></label> @Html.DropDownList("Classifications", ViewData["ClassificationItems"] as SelectList, new { style = "width:100px;" }) <button type="submit" class="u-button"> Search</button> </p>}@if (Model.Count() > 0){ @(Html.Kendo().Grid(Model) .Name("CodeManager") .Columns(columns => { columns.Bound(p => p.CodeID); columns.Bound(p => p.Title); columns.Bound(p => p.Status); columns.Command(command => { command.Edit(); }).Width(200); }) .ColumnMenu() .ToolBar(toolBar => toolBar.Create().Text("Add New Code")) .Sortable() .Scrollable() .Groupable() .Pageable() .Filterable() .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple)) .Resizable(resize => resize.Columns(true)) .DataSource(dataSource => dataSource .Ajax() .Events(events => events.Error("error_handler")) .ServerOperation(false) .Model(model => model.Id(p => p.Id)) .Update(update => update.Action("Code", "CodeManager", new { classifications = @ViewBag.SelectedCatgory })) .Create(create => create.Action("Code", "CodeManager")) ) .Editable(ed => ed.Mode(GridEditMode.PopUp)) )}else{ @Html.Label("No records matched search criteria.");}@model hrmsMVC.Areas.HRMS.Models.CodeModel<fieldset> <legend>Code</legend> @Html.HiddenFor(model => model.CodeID) <div class="editor-label"> @Html.LabelFor(model => model.CodeID) </div> <div class="editor-field"> @Html.EditorFor(model => model.CodeID) @Html.ValidationMessageFor(model => model.CodeID) </div> <div class="editor-label"> @Html.LabelFor(model => model.Title) </div> <div class="editor-field"> @Html.EditorFor(model => model.Title) @Html.ValidationMessageFor(model => model.Title) </div> <div class="editor-field"> @Html.DisplayFor(model => model.Status) </div></fieldset>public class CodeModel { [Key] [ScaffoldColumn(false)] public int Id { get; set; } [DisplayName("Code ID")] [Required(ErrorMessage = "Code is required.")] [StringLength(2, ErrorMessage = "Code can be at most 2 characters")] public string CodeID { get; set; } [Required] public string Title { get; set; } [HiddenInput(DisplayValue = false)] public string Status { get; set; } public bool Active { get; set; } public string Category { get; set; } [ScaffoldColumn(false)] public int UserID { get; set; } }public ActionResult Index(string classifications = "") { ViewData["Classifications"] = new SelectList(Classifications.List, "ClassificationText", "ClassificationText", classifications); var criterion = new Criterion("Category", Operator.Equals, classifications); var codeModels = new List<CodeModel>(); ViewBag.SelectedCatgory = classifications ?? "Type"; if (Request.HttpMethod == "POST") { // var model = _codeRepository.Search(classifications).ToModel(); var model = _codeRepository.GetList(criterion).ToModel(); return View(model); } return View(codeModels); }I am trying to do a custom paging by using mvvm, datasource and template. My problem is I have to use this.set to set the dataSource page() or total pages() to get the value this.get("dataSource").totalPages() or this.get("dataSource").page() refreshed. That is why I set a variable pageRefreshHolder as work-around. Is there some easy way?
var viewModel=kendo.observable({ dataSource:new kendo.data.DataSource({ data:ReportsData, pageSize:12, sort:{ field: "name", dir: "asc" } }), copy:function(e){ this.dataSource.add(e.data); this.set("pageRefreshHolder",this.dataSource.totalPages()); //I have to have this line to get the totalPage work }, goToNextPage:function(){ if(this.dataSource.page()<this.dataSource.totalPages()) this.dataSource.page(this.dataSource.page()+1); else this.dataSource.page(1); $jquery("#reportsArea").find("div#phItem").show("slide",{direction:"right"}, 500); this.set("pageRefreshHolder",this.dataSource.page()); //I have to have this line to get the currentPage work }, goToPrevPage:function(){ if(this.dataSource.page()>1) this.dataSource.page(this.dataSource.page()-1); else this.dataSource.page(this.dataSource.totalPages()); $jquery("#reportsArea").find("div#phItem").show("slide",{direction:"left"}, 500); this.set("pageRefreshHolder",this.dataSource.page()); //I have to have this line to get the currentPage work }, pageRefreshHolder: 1, totalPage: function() { return this.get("dataSource").totalPages(); }, currentPage: function(){ return this.get("dataSource").page(); } }); kendo.bind($jquery("#reportsArea"),viewModel);