Telerik Forums
UI for ASP.NET MVC Forum
1 answer
85 views
Hi,

Is there a way to get the row number that caused the error when a server side validation failed

for example in the function grid_error(e) in this example http://docs.telerik.com/kendo -ui/aspnet-mvc/helpers/grid/ajax-editing

Thanks,
Annie
Daniel
Telerik team
 answered on 10 Nov 2014
4 answers
135 views
First forum post here,  I'm currently in the midst of my free trial using Kendo UI for ASP.NET MVC.  I'm an F# developer and use the MVC5 templates provided by this visual studio extension.  When I right click on the project in solution explorer, I have the option to convert the application into a Telerik UI for ASP.NET Ajax but not an option for MVC.  This is probably because this feature only recognizes the C# MVC5 templates.  Is there any manual work around for this or hope for a future addition to support this.

Thanks,

Steve
Atanas Korchev
Telerik team
 answered on 10 Nov 2014
2 answers
289 views
Hi, 

I am setting up a Kendo sortable with a grid.

@(Html.Kendo().Sortable()
            .For("#MyGrid")
            .Filter(".sortable, table > tbody > tr:not(.k-grid-edit-row)")            
            .Disabled(".disabledDragSort")
            .Cursor("move")
            .HintHandler("ConfigureHint")
            .PlaceholderHandler("placeholder")
            .ContainerSelector("#MyGrid tbody")
            .Events(events => events.Start("onStart").Change("onChange"))
 )

When I set the filter as above it does not work. I am trying to filter for two separate jQuery selectors, separated by a comma. It does not work. When I remove one or the other, for example: .Filter(".sortable"), it works.  What can I do to get this working?






Minh
Top achievements
Rank 1
 answered on 07 Nov 2014
2 answers
990 views
Is there a demo of using a Grid in a Partial View where you are sending the view a model that contains an IEnumerable of what you want in the Grid?  If possible I'd like it to show paging and sorting as well.

I can get this to partially work for me by using BindTo, but once you try to page or sort it does not work out.
Sheldon
Top achievements
Rank 1
 answered on 07 Nov 2014
3 answers
380 views
Please assist. My code is as follows:

Razor:

 @(Html.Kendo().TreeView()
                          .Name("geographyView")
                          .DataTextField("name")
                          .Checkboxes(true)
                          .DataSource(dataSource => dataSource
                                                        .Model(model => model
                                                                            .Id("id")
                                                                            .HasChildren("children")
                                                                            
                                                        ).Read(read => read.Action("Geography", "Home"))
                                                        )
                          )


Controller:

 public JsonResult Geography(long? parentGeographyId)
        {
            if (!parentGeographyId.HasValue)
            {
                ICollection<IGeography2> geography2s = CacheConfig.GeographyCache.FindGeography2();

                var result = geography2s.Select(geography2 => new
                    {
                        geography2.id,
                        geography2.name,
                        children = true
                    }).ToList();

                return Json(result, JsonRequestBehavior.AllowGet);
            }

            if (Convert.ToString(parentGeographyId.Value).Length == 2)
            {
                var geography2Id = (int) parentGeographyId.Value;

                IGeography2 geography2 = _dtoFactory.NewGeography2Dto();

                geography2.id = geography2Id;

                ICollection<IGeography4> geography4s = CacheConfig.GeographyCache.FindGeography4(geography2);

                var result = geography4s.Select(geography4 => new
                    {
                        geography4.id,
                        geography4.name,
                        children = true
                    }).ToList();

                return Json(result, JsonRequestBehavior.AllowGet);
            }

            throw new ArgumentOutOfRangeException("parentGeographyId");
        }

Screenshot is attached.

Basically, the first level of the tree is loaded correctly, and I can see the corresponding AJAX request going out to the controller. However, when I click an entry to expand it in order to fetch the second-level set of entries, nothing happens. The click icon disappears, and no AJAX request is seen going out to the server when viewing the Firefox's Developer Tools' Network tab.

I must be missing something either in the setup of the component (although I do follow Telerik example found here - - or I must be missing a configuration detail such as the version of a supporting component (I am using jQuery 1.9.1 and ASP.NET MVC Q2  2014 SP2).

Thank you in advance for your assistance.
Anton
Top achievements
Rank 1
 answered on 07 Nov 2014
1 answer
287 views
I have an ajax bound grid:

@(Html.Kendo().Grid<LocationViewModel>()
      .Name("locationGrid_#=CustomerID#")
      .Columns(columns =>
      {
          columns.Bound(c => c.Name).Title("Location Name");
          columns.Bound(c => c.Description).Title("Description");
          columns.Bound(c => c.SummaryDescription).Title("Summary Description");
          columns.Bound(c => c.Environment).Title("Environment Name"); //.ClientTemplate("\\#: Environment.Name \\#")
          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
      })
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(10)
          .Read(read => read.Action("GetLocations", "Home", new { customerID = "#=CustomerID#" }))
          .Create(create => create.Action("AddLocation", "Home", new { id = "#=CustomerID#" }))
          .Update(update => update.Action("UpdateLocation", "Home"))
          .Destroy(update => update.Action("DeleteLocation", "Home"))
          .Model(model =>
          {
              model.Id(m => m.LocationID);
          })
          .Events(e => e.Error(@<text>function(e) { onError(e,"locationGrid_#=CustomerID#", "locationErrors") }</text>))
      )
      .ToolBar(toolbar => toolbar.Create().Text("Add Location"))
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Pageable()
      .Sortable()
      .ToClientTemplate()
      )

That uses this view model:
public class LocationViewModel
    {
        public Guid? LocationID { get; set; }
 
        [Required]
        [StringLength(256)]
        public string Name { get; set; }
 
        [StringLength(1024)]
        public string Description { get; set; }
 
        public int TestPointNo { get; set; }
 
        public MarketViewModel Market { get; set; }
 
        [UIHint("EnvironmentEditor")]
        public EnvironmentViewModel Environment { get; set; }
 
        public int TimeZoneGmtOffset { get; set; }
 
        public double Latitude { get; set; }
 
        public double Longitude { get; set; }
 
        public double HAE { get; set; }
 
        public bool Deleted { get; set; }
 
        [StringLength(512)]
        public string SummaryDescription { get; set; }
    }

This is the editor template for Environment:

@(Html.Kendo().DropDownList()
    .Name("EnvironmentViewModel")
    .DataValueField("EnvironmentID")
    .DataTextField("Name")
    .DataSource(d =>
    {
        d.Read(r => r.Action("GetEnvironmentsJsonResult", "Home").Data("getCustomerID()")).ServerFiltering(true);
    }
    )
    .SelectedIndex(0)
)

Right now everything "works" but I'd like to display the Environment.name instead of [Object object] in the grid. If I use the commented out client template than the add function returns a javascript error "Uncaught ReferenceError: Environment is not defined". If I bind the column to Environment.Name than the editor with the ddl doesn't work. How do I bind to the EnvironmentViewModel but just display the name in the grid?









Daniel
Telerik team
 answered on 07 Nov 2014
1 answer
131 views
Hi:
I am new to using Kendo UI. I am using MVC4  (VS 2012) with Kendo Mvc wrappers. I am trying to display a DropdownlistboxFor associated with a model item. Then during listbox change event i want to save that model (in the controller). I have hardcoded listbox items added to the listbox like in the code below. Should i post an ajax call which will call a controller method that saves model? How do i do this ajax post with model data sent to the controller action with the combo box updated data?

Is there any other way?
Thank you so much for your help.

=========================================
My model code is:
public class PackageModelView
    {
        public int DefaultReason { get; set; }
}
=========================================
View code (say named file Package.cshtml) has:
@using .<model namespace directory>
@model PackageModelView

@(Html.Kendo().DropDownListFor(model => model.DefaultAction)
                        .DataTextField("Text")
                        .DataValueField("Value")
                        .BindTo(new List<SelectListItem>()
                        {
                            new SelectListItem()
                            {
                                Text = "Active",
                                Value = "1"
                            },
                            new SelectListItem()
                            {
                                Text = "In-active",
                                Value = "2"
                            }
                        })
                       .Value("1")
                    )


Petur Subev
Telerik team
 answered on 07 Nov 2014
1 answer
54 views
My old code:
      
function updateReconcileCB(cb) {
    var grid = $("#Receipts").data("kendoGrid");
    var di = grid.dataItem(grid.select());
    di.selected = cb.checked;
}


Was working just fine
however, since updating to: Kendo 2014.2.1008
This code works sporadically and although the Checkboxes get checked visually this code throws an error and the grid line is not recognized as checked/selected??

how Do I modify the code to fix?
or do I just revert back to old Kendo scripts? 
Kiril Nikolov
Telerik team
 answered on 06 Nov 2014
3 answers
339 views
Hi experts,

First of all, sorry for asking some basic stuff about the grid as I'm quite new on the kendo grid.

As mentioned in the title, I would like to know how do I generate the link that expands the child grid from ClientRowTemplate.

What I'm doing now is altering the hierarchy.cshtml from the demo.  But not getting any luck to achieve this.

Many Thanks,

Victor
Dimiter Madjarov
Telerik team
 answered on 06 Nov 2014
10 answers
922 views
Hi,

with this view

 

 

@(Html.Kendo().Grid<Reviews.Models.Review>().Name("ReviewGrid").Columns(columns =>
{
 
    columns.Bound(p => p.Customer);
    columns.Bound(p => p.Location);
    columns.Bound(p => p.Title).ClientTemplate("<strong>#: Title #</strong>");   //This works  
    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
 
})
.ToolBar(toolbar => toolbar.Create().Text("Ný Skyrsla"))
    .DetailTemplate(detail => detail.ClientTemplate(
        Html.Kendo().Grid<Reviews.Models.ReviewCategory>()
            .Name("ReviewCategory_#=ReviewID#")
            .Columns(columns =>
            {
                columns.Bound(o => o.TableNo);
                columns.Bound(o => o.Category);
                columns.Bound(o => o.Comment);
                //columns.Bound(o => o.PerformedDate);
               // columns.Bound(o => o.Id).ClientTemplate("<img alt='#: Id #' src='"
               //+ Url.Content("~/Report/ViewPic/")
               //     + "#: Id #' />").Title("Picture");
                columns.Bound(o => o.TableNo).ClientTemplate("<strong>#: TableNo #</strong>");//tthis does not work   
                 
                columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
            })
            .ToolBar(toolbar => toolbar.Create())
        
 
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Pageable()
            .Sortable()
            .Scrollable()
            .DataSource(dataSource => dataSource
                .Ajax()
 
                    .Events(events => { events.Error("error_handler"); })
                    .Model(model => model.Id(p => p.Id))
                        .Create(update => update.Action("ReviewCategory_Create", "Home", new { reviewId = "#=ReviewID#" }))
                    .Read(read => read.Action("ReviewCategory_Read", "Home", new { id = "#=ReviewID#" }))
                        .Update(update => update.Action("ReviewCategory_Update", "Home", new { reviewId = "#=ReviewID#" }))
                    .Destroy(update => update.Action("ReviewCategory_Destroy", "Home"))
 
                )
                .ToHtmlString()
 
))
 
.Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
            .Events(events => { events.Error("error_handler"); })
        .Model(model => model.Id(p => p.ReviewID))
        .Create(update => update.Action("Review_Create", "Home"))
        .Read(read => read.Action("Review_Read", "Home"))
        .Update(update => update.Action("Review_Update", "Home"))
        .Destroy(update => update.Action("Review_Destroy", "Home"))
    )
)

The first clientTemplate works and

#: Title # get bound to Review.Title.

The second clientTemplate does not work, a js error comes , it says can not bind to TableNo. Writing Title instead of Table No will however display the title from Review class. so eventhourgh my grid is bound to ReviewCategory class the clienttemplate is displaying value from Review class.

Is this a bug ?.

Best

Ole

 

 

 

Nikolay Rusev
Telerik team
 answered on 06 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
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
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?