Telerik Forums
UI for ASP.NET MVC Forum
7 answers
2.7K+ views
Is there a way to only allow the user to control the selectable file types?

I know I can get the information once they select the file but I'd prefer to filter the list to only .pdf, or whatever.
Dimiter Madjarov
Telerik team
 answered on 31 Mar 2015
3 answers
102 views
I have issues in using the spinners of numeric textbox in IE10(Standards mode as well as compatiblity mode)
but this doesn't work in the demo site either

http://demos.telerik.com/aspnet-mvc/numerictextbox/index

Any workarounds for this ?


Kiril Nikolov
Telerik team
 answered on 31 Mar 2015
1 answer
292 views
I have a form that has a standard datepicker that highlights specific dates.  Based on the example in the demo section, this is what the control is set up as:
@(Html.Kendo().DatePicker()
      .Name("datepicker")
      .Value(DateTime.Today)
      .HtmlAttributes(new {style = "width: 100%;"})
      .Footer("Today - #=kendo.toString(data, 'd') #")
      .MonthTemplate("# if ($.inArray(+data.date, events) != -1) { #" +
                     "<div class='" +
                     "# if (data.value > 0) { #" +
                     "order" +
                     "# } #" +
                     "'>#= data.value #</div>" +
                     "# } else { #" +
                     "#= data.value #" +
                     "# } #"))

In the Javascript, I have this:

var today = new Date(),
    events = [];
 
$.ajax({
    url: "GetOrderDates?shipOrderNbr=" + $("#shiporder").val(),
    dataType: "json",
    success: function (result) {
        events = []; //clear the array of any preexisting dates that may have been loaded
        $.each(result, function (index, value) {
            events.push(new Date(value)); //01/01/2015, etc
         }); 
     }
});

The above code works; the ajax call returns a collection of strings that are all parsed into date objects and pushed in the the events array.

However, at any given time, the collection of dates can change depending on the users input.  However, once the datepicker control is initialized, changing the dates array doesn't refresh the highlighted dates in the control (in effect, once the MonthTemplate is rendered, it never reloads).

Is there a way to dynamically change the highlighted dates client side?
Daniel
Telerik team
 answered on 30 Mar 2015
1 answer
185 views
Hello Telerik Team,

I want my kendo grid built in Asp.Net MVC 4 receive any object model, in other words, dynamic. The action method of my controller not show errors, but the data not displayed in kendo grid. Any suggestions?

View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
 <% Html.Kendo().Grid<dynamic>()
    .Name("GridTeste")
    .Columns(columns =>
    {
        if (Model != null)
        {
            foreach (var x in Model)
            {
                 columns.Bound(x.Value, x.Key.ToString()).Title(x.Key).Encoded(false);
            }
        }
    }
    )
         .DataSource(datasource => datasource
         .Ajax()
         .Read(read => read.Action("CarregarDados", "ImportacaoTabelaPropria", new { acao = "Brasindice", ajuste = "", nova_validade = "" }))
         )
        .Navigatable()
        .Scrollable()
        .Selectable()
        .HtmlAttributes(new { style = "width:100%;height:400px;", id = "GridTeste" })
        .Render();
 %>

My Action in Controller: 

        public ActionResult CarregarDados(string acao, string ajuste, string nova_validade, [DataSourceRequest] DataSourceRequest request)
        {
            PreencherTabelaPropria tabela_propria = new PreencherTabelaPropria();
            PreencherBrasindice bras = new PreencherBrasindice();
            Dictionary<string,System.Type> colunas = new Dictionary<string,Type>();
            if (acao.Equals("Tabela propria"))
            {
                return Json(tabela_propria.PreencherTabelaPropriaValores(), JsonRequestBehavior.AllowGet);
            }
            if (acao.Equals("Brasindice"))
            {
                if (bancoBrasindice != null)
                {
                    if (!String.IsNullOrEmpty(ajuste))
                    {
                        foreach (var x in bancoBrasindice)
                        {
                            x.Ajuste_liberado = ajuste;
                            if (!String.IsNullOrEmpty(nova_validade))
                                x.Nova_validade = DateTime.Parse(nova_validade);
                        }
                        return Json(bancoBrasindice, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    List<ImportacaoBrasindiceModel> brasindice = bras.PreencherBrasindiceValores();
                    //atualizar o modelo com os valores de ajuste e validade
                    foreach (var x in brasindice)
                    {
                        x.Ajuste_liberado = ajuste;
                        if (!String.IsNullOrEmpty(nova_validade))
                            x.Nova_validade = DateTime.Parse(nova_validade);
                    }
                    bancoBrasindice = brasindice;
                }
                Dictionary<string, System.Type> colunas2;
                PropertyInfo[] propriedades = typeof(ImportacaoBrasindiceModel).GetProperties();
                colunas2 = new Dictionary<string, Type>();
                foreach (PropertyInfo x in propriedades)
                {
                    colunas.Add(x.Name, x.PropertyType);
                }
                //return PartialView("~/Views/ImportacaoTabelaPropria/TesteGridParcial.ascx", Json(bancoBrasindice, JsonRequestBehavior.AllowGet));
                return Json(bancoBrasindice.ToDataSourceResult(request), RenderPartialViewToString("~/Views/ImportacaoTabelaPropria/TesteGridParcial.ascx", colunas), JsonRequestBehavior.AllowGet);

            }
            return Content("");
        }

My method to convert Partial View to string: 

protected string RenderPartialViewToString(string viewName, object model)
        {
            if (string.IsNullOrEmpty(viewName))
                viewName = ControllerContext.RouteData.GetRequiredString("action");

            ViewData.Model = model;

            using (StringWriter sw = new StringWriter())
            {
                ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
                ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
                viewResult.View.Render(viewContext, sw);

                return sw.GetStringBuilder().ToString();
            }
        }


















Daniel
Telerik team
 answered on 30 Mar 2015
3 answers
95 views
I am using kendo color picker and its doesn't work fine in IE10(standard mode as well as compatibility mode)

I later found this issue in demo either
http://demos.telerik.com/aspnet-mvc/colorpicker/index 

I am not able to select any color from the color picker in IE10

I am using win 7 64 bit environment.
Any workaround for this ?
Dimiter Madjarov
Telerik team
 answered on 30 Mar 2015
3 answers
157 views
Hi.
Model:
public class Family{
   public int Id {get;set;}
   public string FamilyName {get;set;}
   public int StreetId {get;set;}
}
public class Street {
   public int Id {get;set;}
   public string StreetName {get;set;}
}
There is a Grid with a toolbar in which a dropdownwlist with the streets. Its role is to filter  the Family data in the Grid by Street - it is work fine.
But...
I want when I adding a new family the StreetId value was taken from the  Dropdownlist (Id of street). How can I do that?
vitaliy
Top achievements
Rank 1
 answered on 30 Mar 2015
6 answers
69 views
I would like to force the scheduler to be shown in Danish, I have managed to get the Months, day names shown in Dansih (Javascript), but the other texts (Today, Show buisness hours, and others) on the site is still shown in English.
I have included the Kendo.Mvc.resources.dll for da-DK.

Thanks very much in advance :-)
Vladimir Iliev
Telerik team
 answered on 30 Mar 2015
4 answers
191 views
Hi.

I'm having a problem with the filter on a ForeignKey column.

The first time I select a status in the dropdown in the filter menu and click the "Filter" button,  nothing happens, but if I change the status and click filter again, it filters as it is supposed to.

Also if I select one status without clicking the "Filter" button, then selects a new status and then clicks the "Filter" button, it filters works.

Got any tip that can help me with this? I have updated to the lates build.

The code:

<div class="col-lg-12">
    @(Html.Kendo().Grid<Order>()
          .Name("orderGrid")
          .Columns(columns =>
          {
              columns.Bound(order => order.OrderNo).Title("Order no.");
              columns.ForeignKey(order => order.Status.Description, Model.StatusList, "Description", "Description").Title("Status");
          }
          )
          .Filterable(filter => filter.Enabled(true).Mode(GridFilterMode.Menu))
          .AutoBind(true)
          .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action("GetOrders", "OrderSurface"))
              )
          )
</div>
Wolfgang
Top achievements
Rank 1
 answered on 27 Mar 2015
3 answers
390 views
Hi, 
I have a model like below:

public class SysUnit : BaseModel
    {
        public string Name { get; set; }
        public string Prefix { get; set; }
 
        public SysUnitGroup SysUnitGroup { get; set; }
 
    }
public enum SysUnitGroup
    {
        Money,
        Length,
        Weigh,
    }


When i used scaffold template of Telerik, it is not generating dropdown for Enum at insert and edit actions. 

I searched and try lots of things to bind enum in Grid Editview.. Is there any tutorial ? 



Alexander Popov
Telerik team
 answered on 27 Mar 2015
3 answers
485 views
The below Url's requests work and return data.

http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+eq+11)
http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+gt+11)
http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+lt+11)

The below Url requests do not work and return an exception. This is Greater than or Equal to, Less that or Equal To and Not Equal to

http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+ge+11)
http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+le+11)
http://localhost:63455/api/data/gethistory?$top=5&$filter=(Id+eq+1+and+PaymentId+ne+11)

I am using a kendo grid with server filtering turned on and the grid calls a data source which is a web API controller that accepts a custom Model binder (by implementing IModelBinder) and on that model binder, it does the below which fails. 

var filter = "(TransportProviderId eq 1 and PaymentRequestId ge 5)"
request.Filters = FilterDescriptorFactory.Create(string.Join("~", filter.Split(' ')));


{"Message":"An error has occurred.","ExceptionMessage":"Expected RightParenthesis","ExceptionType":"Kendo.Mvc.Infrastructure.Implementation.FilterParserException","StackTrace":" at Kendo.Mvc.Infrastructure.Implementation.FilterParser.Expect(FilterTokenType tokenType)\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.ParseNestedExpression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.PrimaryExpression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.ComparisonExpression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.AndExpression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.OrExpression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.Expression()\r\n at Kendo.Mvc.Infrastructure.Implementation.FilterParser.Parse()\r\n<br>at Kendo.Mvc.Infrastructure.FilterDescriptorFactory.Create(String input)\r\n at RequestModelBinder.BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
Petur Subev
Telerik team
 answered on 27 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?