Telerik Forums
UI for ASP.NET MVC Forum
1 answer
193 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
109 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
177 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
71 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
204 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
409 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
520 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
1 answer
197 views
I am looking at the new filtering feature of the grid - Multi Checkboxes (http://demos.telerik.com/aspnet-mvc/grid/filter-multi-checkboxes)

I can't work out how I can dynamically change the filter list based on the contents of the grid.

I currently have a drop down list in the toolbar of the grid, that users can select various pre-defined filtered datasets. I'd like the checkbox list in the filter menu to only display the available values in the grid. I don't mind doing this via an AJAX call and manually populating the data but I can't work out to get a reference to the filter menu. (I will have multiple filter menus on the grid)

Any pointers?

Thanks
Petur Subev
Telerik team
 answered on 27 Mar 2015
2 answers
85 views
Hi,

Since we've updated to the 2015 Q1 update a number of our DropDownLists have stopped selecting the top item on page load.  This is the issue we're having, seems to be consistent with the following criteria:

-DropDownListFor a default int property (so value is 0 by default)
-DataSource is a small collection contained in the ViewBag with no item of ID 0

eg
@(Html.Kendo().DropDownListFor(x => x.ClientID)
                            .DataTextField("name")
                            .DataValueField("id")
                            .BindTo((System.Collections.IEnumerable)ViewBag.Clients)
                        )

These were working before the update, and just defaulting to an index of 1, but even trying to set the SelectedIndex property fails to alleviate the problem.   Any advice you might have would be much appreciated.

Thanks,
Kevin











Georgi Krustev
Telerik team
 answered on 27 Mar 2015
4 answers
1.7K+ views
Hello,
I have a context menu displayed on right clicking kendo grid like this.
@(Html.Kendo().ContextMenu()
        .Name("menuGrid")
        .Target("#Grid_ObjActivity")
        .Orientation(ContextMenuOrientation.Vertical)
        .Animation(animation =>
        {
            animation.Open(open =>
            {
                open.Fade(FadeDirection.In);
                open.Duration(500);
            });
        })
        .Items(items =>
        {

            items.Add()
               .Text("Herunterladen")
               .ImageUrl(Url.Content("~/Images/Download.png"));
            items.Add()
              .Text("Löschen")
              .ImageUrl(Url.Content("~/Images/Delete.png"));

        })
        .Events(e => e.Select("ContextClick"))

    )

This is ok but i would like to have the items added dynamically depending on type of row clicked on grid. Each row in grid has a different type and right clicking show a different context menu with different action.

How can i achieve this in my razor view.

Thanks

Anamika
Daniel
Telerik team
 answered on 27 Mar 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
DateTimePicker
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?