Using the MVC KendoGrid I've created a grid with custom filtering on some columns. Following the demo at http://demos.telerik.com/aspnet-mvc/grid/persist-state, I added code to save and load the state. I find that after saving then loading, I've lost the custom filters. Comparing the options object when saving and then when loading confirms this:
Column 0 when saving:
columns:Array[41] 0:Object encoded:true field:"ShippingUnit" filterable:Object ui:shippingUnitFilter(element) __proto__:ObjectColumn 0 when loading:
columns:Array[41] 0:Object encoded:true field:"ShippingUnit" filterable:Object __proto__:ObjectNotice the ui element is missing on the load. Upon further research, I found it's the stringify function during save that drops the ui: element Any workarounds? Any examples of where this works?
Here's the code:
@model Panther.Portal.Areas.Inventory.Models.InventoryVM@{ViewBag.Title = "Inventory";}@using Kendo.Mvc.UI<link href="~/Content/kendo/2016.1.226/kendo.default.min.css" rel="stylesheet" /><link href="~/Content/kendo/2016.1.226/kendo.common.min.css" rel="stylesheet" />@section Scripts { <script src="~/Scripts/kendo/2016.1.226/kendo.all.min.js"></script> <script src="~/Scripts/kendo/2016.1.226/kendo.aspnetmvc.min.js"></script> <script src="~/Scripts/kendo/2016.1.226/kendo.grid.min.js"></script> <script src="~/Scripts/kendo/2016.1.226/kendo.all.min.js"></script>}<div class="box wide"> <a href="#" class="k-button" id="save">Save State</a> <a href="#" class="k-button" id="load">Load State</a></div><div id="KendoGrid"> @(Html.Kendo().Grid(Model.InventoryList) .Name("grid") //.ColumnMenu() .Columns(columns => { columns.Bound(c => c.ShippingUnit).Title("Shipping Unit").Filterable(filterable => filterable.UI("shippingUnitFilter")); columns.Bound(c => c.InventoryStatus).Title("Inventory Status").Filterable(filterable => filterable.UI("inventoryStatusFilter")); columns.Bound(c => c.ProductId).Title("Product ID").Filterable(filterable => filterable.UI("productIDFilter")); //More Columns... }) .Resizable(resize => resize.Columns(true)) .Reorderable(reorder => reorder.Columns(true)) .Sortable() .Selectable(selectable => selectable .Mode(GridSelectionMode.Multiple)) .Filterable(filterable => filterable .Extra(false) .Operators(operators => operators.ForString(str => str.Clear())) ) .Pageable(pageable => pageable .Refresh(true) .PageSizes(true) .ButtonCount(5)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("FilterMenuCustomization_Read", "Inventory")) .PageSize(15) ) )</div><script type="text/javascript"> $(function () { var grid = $("#grid").data("kendoGrid"); $("#save").click(function (e) { e.preventDefault(); var opt = grid.getOptions(); var foo = kendo.stringify(grid.getOptions(), ['week', 'month']); var bar = JSON.parse(foo); localStorage["kendo-grid-options"] = kendo.stringify(grid.getOptions()); }); $("#load").click(function (e) { e.preventDefault(); var options = localStorage["kendo-grid-options"]; if (options) { var foo = JSON.parse(options); grid.setOptions(JSON.parse(options)); } }); }); function shippingUnitFilter(element) { element.kendoAutoComplete({ dataSource: { transport: { read: "@Url.Action("FilterMenuCustomization_ShippingUnits")" } }, optionLabel: "--Select Value--" }); } function inventoryStatusFilter(element) { element.kendoDropDownList({ dataSource: { transport: { read: "@Url.Action("FilterMenuCustomization_InventoryStatus")" } } }); }</script>I have tried most of the examples that come with the grid. My problem is this.
this is my class that is bound to this view
@model IEnumerable<VaultLeitarvefur.Models.vaultNidurstodur>
this is my grid that is bound to said model
@(Html.Kendo().Grid<VaultLeitarvefur.Models.vaultNidurstodur>(Model)
.Name("grid")
.Columns(columns =>
{
//columns.Bound(p => p.file.Name).Filterable(false);
columns.Bound(p => p.Id).Filterable(false).Visible(false);
columns.Bound(p => p.file.Name).Title("Heiti");
columns.Bound(p => p.file.ModDate).Format("{0:dd/MM/yyyy}").Title("Breytingardags");
columns.Bound(p => p.file.VerNum);
columns.Bound(p => p.file.DesignVisAttmtStatus);
columns.Bound(p => p.file.FileStatus);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
I have a search textbox and a search button
I have home/index which returns a list<vaultNidurstodur> which is the class that I want to display in the grid.
currently when I start the project index is displayed and all data is populated in the grid, and filtering within the grid itself works fine.
I want to be able to enter data into the textbox and do a contains on that string in vaultNidurstodur.Name column , when I try this the data in the grid never gets filtered. I would prefer if this was a ajax call so the grid can be updated without a refresh.
I would like to start off with an empty grid and then use the search string to filter from list<> the reason is that I can expect 40-50000 results with file references and I would rather not send all that data.
Can you point me in the right direction ?
Regards,
Emil Thor Emilsson
Developer
Snertill.is

I am using an MVC grid that has a toolbar, with a custom button
toolBar.Custom().Text("Recalculate Assets").Action("Edit", "AssetPlanning", new { recalculate = true }).HtmlAttributes(new { title = "Warning: This could take multiple minutes to fully complete", data_toggle = "tooltip", id = ("calcButton" + uniqueName), onClientClick = "alert('reclacing');" });
This actionresult can take upto a minute to run. I would at the very least like to update the button to say calculating with a little spinner and whatnot
var buttonID = "#calcButton" & String(@uniqueName.ToString());$(buttonID).click(function () { recalculating(); });function recalculating() { alert("reclacing"); $(buttonID).addClass("btn btn-lg btn-warning"); $(buttonID).html('<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Recalculating');}
I would think that somewhere along the way the function would get called or an alert box would show, but nothing appears on the client side. I'm guessing that the action gets called first and the client click event just is never called. What can I do to make the client code called first or run together?

I have a grid that has a column bound to it:
columns.Bound(p => p.FailureStrategyLookup).ClientTemplate("#=FailureStrategyLookup.FailureStrategy#").Width(100);
If the FailureStrategyLookup is NOT null, everything works fine. But when it IS NULL it can't bind the the object and I get an error saying "FailureStrategy" can't be found for a null value (or something to that affect). How can I get thsi working for a COMPLEX type when it's null?
public class FailureStrategyLookupViewModel{ [Required] public int FailureStrategyID { get; set; } [Required] [DisplayName("Maintenance Strategy")] public string FailureStrategy { get; set; }}ssdsdf
@using eRPortalDashboard.Models;@using Kendo.Mvc.UI;@model FailureStrategyLookupViewModel@(Html.Kendo().DropDownListFor(m => m) .DataValueField("FailureStrategyID") .DataTextField("FailureStrategy") .BindTo((System.Collections.IEnumerable)TempData["FailureStrategyLookups"]))Hi
I have been going through an issue with Kend DropDownList's OptionLabel.
I have attached an image of the UI, if you see in it the optionLabel is kind of sticking to the top of the dropdown when I open it, even if I scroll the dropdown that option label keeps on showing plus its size is not like normal entry if you see the selected item highlighted in blue is comparatively wide vs the height of the option label.Also the second image with smaller drop down is also showing the same issue "Select Denial Reason" option label has smaller height compared to one of the values in dropdown like DENIED FUNCTIONAL etc.
Below is my code how I am defining it.
Please help me in tackling this issue so that optionlabel starts behaving normal.
Thanks
Rizwan
Hi,
I have a Telerik UI Grid with a filterable column set to Multi, and Search set to True. Default placeholder text is "search".
How do I change this text?
Hello
We have a Listview that populates with an IEnumerable<object> The data source is set and the read called when a Kendo DropdownList.Change Event is called.
We have found that the first 1/2 the records with generate elements with data-uid, role="option" & aria-selected="false", while the latter 1/2 do not. There is no difference in the records, if we add a single record to the list at a time, it will produce the same result, the first 1/2 with, the second 1/2 without.
we are using an external template (pls see below):
<script type="text/x-kendo-tmpl" id="availableAccessRightsTemplate">
<div style="padding: 8px 0 8px 10px;letter-spacing:.2px;">
<span data-toggle="tooltip" title="#= Description#"> #= DisplayName# </span>
</div>
<hr style="margin-top: 0;margin-bottom: 0;" />
</script>
We see this behavior on 2 different ListViews, albeit on the same page with the same data types (objects).
Thanks for your help in advance
So, I've tried to get this working following many threads and articles and I can't get it to work. The value posts back to the controller fine, but I can't get it to set the default selected item on the DropDownList nor can I get it to display the text of the selected item when I select an option. If I use a client template to try and grab the text, it throws an error (Cannot read property 'Text' of null) and won't show any items in the grid. For this one, I'm not using just an IEnumerable list of ViewModels (like most of the examples show) to populate the DropDownList, I'm using a SelectList. I have it working fine in another project with an IEnumerable list of ViewModels, but I just can get it working with a SelectList and I don't want to create a ViewModel for these static options. Please help! Thanks!
Here's my grid:
@(Html.Kendo().Grid<Tracker.Areas.Admin.Models.AdHocLocationViewModel>() .Name("gridAdHocLocations") .Columns(columns => { columns.Bound(c => c.LocationName).Title("Reviewer Location"); columns.Bound(c => c.Packet).Title("Added to"); columns.Bound(c => c.CreateDt).Title("Date Added").Width(120).Format("{0:MM/dd/yyyy}"); columns.Bound(c => c.Action).Title("Selection").ClientTemplate("#=Action.Text#").Width(180); }) .Editable(e => e.Mode(GridEditMode.InCell)) .ToolBar(t => t.Save()) .Sortable() .Pageable(pageable => pageable .Refresh(true) .PageSizes(true) .ButtonCount(5)) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Batch(true) .ServerOperation(false) .Model(s => { s.Id(model => model.LocationId); s.Field(f => f.LocationName).Editable(false); s.Field(f => f.Packet).Editable(false); s.Field(f => f.CreateDt).Editable(false); s.Field(p => p.Action).DefaultValue( ViewData["defaultAction"] as SelectListItem); }) .Read(read => read.Action("LocationsAdHoc_Read", "Location")) .Update(update => update.Action("LocationsAdHoc_Update", "Location")) ) )Here's my editor (I've also tried it strongly typed using DropDownListFor):
@(Html.Kendo().DropDownList() .Name("Action") .DataValueField("Value") .DataTextField("Text") .OptionLabel("Select Action") .BindTo((SelectList)ViewData["actions"]))Here's my model:
public class AdHocLocationViewModel { [ScaffoldColumn(false)] public int LocationId { get; set; } public string LocationName { get; set; } public string Packet { get; set; } public int ActionId { get; set; } public DateTime CreateDt { get; set; } [UIHint("AdHocLocationEditor")] public SelectListItem Action { get; set; } }