Telerik Forums
UI for ASP.NET MVC Forum
1 answer
121 views
I am having an issue when working with DropDownList components. After binding the component if a vertical scrollball is needed (too many records at once), if you scroll down in attempt to select a value, the combo box get closed. At second attempt the combo works fine and you can scroll down with any problem. 
Our project is running with kendo.web.js version “v2013.2.918”, due to internal project policies we are not allow to change neither .js version nor kendo.mvc dll. 
Is there any workaround to this issue for this version?

<div class="controlBlock">            <label>*@Html.RawLocalized(WorkspaceMessageKeys.WorkspaceType).ToString()</label>
            @(Html.Kendo().DropDownListFor(m => m.WorkSpaceTypeId)
                    .Name("WorkSpaceTypeId")
                    .HtmlAttributes(new { @class = "check" })
                    .DataTextField("WorkSpaceTypeDesc")
                    .DataValueField("WorkSpaceTypeId")
                    .OptionLabel(Html.RawLocalized(WorkspaceMessageKeys.Select).ToString())
                    .DataSource(source =>
                    {
                        source.Read(read =>
                        {
                            read.Action("FindWorkSpaceTypes", "WorkSpace")
                                .Type(HttpVerbs.Post);
                        })
                        .ServerFiltering(true);
                    })
                )
            <div>
                @Html.ValidationMessageFor(m => m.WorkSpaceTypeId)
            </div>
</div>

Thanks in advance. 



Georgi Krustev
Telerik team
 answered on 25 Nov 2014
3 answers
488 views
The implementation of GridBuilder<T>.TableHtmlAttributes() suggests that you should be able to call it multiple times and have the results merged:

public GridBuilder<T> TableHtmlAttributes(IDictionary<string, object> attributes)
{
  this.Component.TableHtmlAttributes.Clear();
  Kendo.Mvc.Extensions.DictionaryExtensions.Merge(this.Component.TableHtmlAttributes, attributes);
  return this;
}

However, when I try to call TableHtmlAttributes more than once on the same grid, the attributes added by the first call are removed by the second, even though the names do not conflict:

.TableHtmlAttributes(new KeyValuePair<string, object>("k-grid-tab-new-row", null).ToDictionary())
.TableHtmlAttributes(new KeyValuePair<string, object>("class", "custom-table-hover table table-bordered no-footer k-grid-single-line ").ToDictionary())

How can I prevent this behavior? 

We have several attribute-based custom functions that we have built on top of Kendo grids, and I would like to create optional extension methods for the MVC builder to add these in the grid definition, like this:

public static GridBuilder<T> TabNewRow<T>(this GridBuilder<T> builder)where T : class
{
    return builder.TableHtmlAttributes(new KeyValuePair<string, object>("k-grid-tab-new-row", null).ToDictionary());
}

The above approach is not possible if each call overwrites the previous ones.
Dimo
Telerik team
 answered on 25 Nov 2014
1 answer
370 views
I have kendo treeview to show history list, so initially I have 1 item then load its children from remote data.
Here is my razor code :
01.@(Html.Kendo().TreeView()
02.      .Name("tvHistory")
03.      .Animation(animation => animation.Expand(open =>
04.                              {
05.                              open.Expand(ExpandDirection.Vertical);
06.                              open.Fade(FadeDirection.In);
07.                              }))
08.      .Items(treeview => treeview.Add().Text("History").Id(Model.Id.ToString()))
09.      .DataTextField("Description")
10.      .AutoBind(false)
11.      .DataSource(dataSource => dataSource.Read(read => read.Action("History", "Reservation")))
12.)


So technically when this "History" item being clicked it will call datasource read action and load its children items from controller. Yet its produce an error in console instead of calling the controller.

error image

Here is my controller code and the class that I return to client
01.[HttpGet]
02.public ActionResult History(int id)
03.{
04.    IList<ReservationHistory> histories = _reservationService.GetHistoryFor(id).DataList;
05.    IList<ReservationHistoryViewModel> viewModels = histories.ToModel<ReservationHistory, ReservationHistoryViewModel>();
06.     
07.    return Json(viewModels, JsonRequestBehavior.AllowGet);
08.}
09. 
10.public class ReservationHistoryViewModel
11.{
12.    public int Id { get; set; }
13.    public int ReservationId { get; set; }
14.    public string Description { get; set; }
15.}


any suggestion to fix this? Thanks
Vladimir Iliev
Telerik team
 answered on 25 Nov 2014
1 answer
1.2K+ views
I have a grid with a custom toolbar template defined, full of custom controls. I would like to add a button to export the grid contents to excel, however based on the example .ToolBar(tools => tools.Excel()) seems to just arbitrarily add a button to the toolbar. Is there a way to add my own button to my toolbar template and have it be recognized as the export to excel button?
Dimiter Madjarov
Telerik team
 answered on 24 Nov 2014
1 answer
86 views
I am using latest trial Kendo.Mvc.dll
I have grid with popup editing.

  .Sortable()
        .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.PopUp).TemplateName("Template").Window( w => w.Width(960)))       
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(p => p.NSTemplateID))              
            .Read(read => read.Action("Templates_Read", "TemplateManager").Data("additionalData"))                  
            .Update(update => update.Action("Templates_Update", "TemplateManager"))
            .Events(events => events.Error("error_handler").RequestStart("request_start"))                                 
        )

All working good but when authentication timeout - no errors.
How I can handle timeout and show warning to user?


Daniel
Telerik team
 answered on 24 Nov 2014
1 answer
860 views
Hi there,

Having previously used the RadControls ASP.NET AJAX Editor, we had a requirement to store two copies of the entered information - one with HTML formatting and one without for reporting purposes.

I seem to recall this was quite trivial to implement at the time, as the Editor control provided a property which just had the plain text which we could store separately.

However, I can't seem to find an obvious way to achieve this with the Kendo Editor - unless I am missing something?

Thanks,

Paul
Kiril Nikolov
Telerik team
 answered on 24 Nov 2014
4 answers
129 views
I cannot find the treelist feature in my trial version I downloaded.

V2014.2.1008

THanks.
Yogesh
Top achievements
Rank 1
 answered on 21 Nov 2014
4 answers
195 views
As we all know using an IIFE (immediately-invoked function expression) is all the rage these days and a best practice for isolation of javascript code from the dreaded global scope. 

We are creating a dashboard in which it is possible the same widget is placed on the dashboard twice by the user. So, the js has to be isolated to prevent collisions. 

One issue we had was that when we provide a Data("FunctionName") function name to a grids datasource since the helper renders the script inline if the function was declared in the IIFE a js undefined error occurs. This issue would also occur with any event handlers that you set up with the grid. 

One possible work around could be to have the IIFE (really now using the revealing module patter) given a name. But, still, this would mean putting the js into the razor view and somehow coming up with a unique name for that instance of the views function and prefixing the event handlers with it. But, I really don't like this because the js in the view isn't minified and cached.

Other than moving to client side configuration, basically nullifying the benefit of the MVC helpers, is there any possible way this could work? Perhaps the helper could somehow allow you to render the HTML separately from the js? Even that wouldn't be perfect since then all the js would have to be in the razor view.

Any other ideas or considerations. 
Bob
Top achievements
Rank 1
 answered on 20 Nov 2014
1 answer
209 views
I have several text boxes that are numeric values and would like for them to always have 2 decimal places (values can vary from less than 1 to several thousand) when displayed.  I have tried different masks but can not find one that will work for this.  I am also open to using the Numeric text box but would not want the increment and decrement arrows to display as those are not useful for this application.
Georgi Krustev
Telerik team
 answered on 20 Nov 2014
2 answers
416 views
Suppose I have an enum that I'd like to use in a Grid, using the _underlying value_ as the cell value:

public enum Currency : int {
   USD = 0,
   GBP = 1
}

The editor is thus something similar to:

@(Html.Kendo().DropDownListFor(m => m)
      .BindTo(Enum.GetValues(typeof(Currency)).Cast<Currency>().Select(v => {
          return new DropDownListItem()
          {
              Text = v.DisplayName(),
              Value = ((int)v).ToString(),
              Selected = v == Model,
          };
      }).ToList()))

If I don't include an entry in the data source model for the field, the field defaults as expected to 0.

However, if I include the following entry in the data source model, Kendo attempts to default the value to "usd":

model.Field(d => d.Currency).DefaultValue((int) Currency.USD);

This isn't a problem for this case, as I can just leave off the model configuration. However, it becomes a problem if I change the type of the column to Nullable<Currency> because there is no way to default the value to 0. Not configuring the model attempts to use null (which causes Kendo grid to throw an exception), and attempting to configure the model uses "usd", which is invalid.

I have attempted manually setting the schema using JS:

$(document).ready(function () {
     $("#MyGrid").data("kendoGrid").dataSource.options.schema.model.fields.Currency.defaultValue = 0;
}

However when I add a new column, the grid still attempts to use "usd" as the default value.

Please advise how to set the default value to 0 for a column type of Nullable<Currency>.



Daniel
Telerik team
 answered on 20 Nov 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?