Telerik Forums
UI for ASP.NET MVC Forum
5 answers
196 views
As per:
 
http://www.kendoui.com/forums/mvc/general-discussions/update-destroy-operations-trigger-the-error-event-of-the-datasource-after-updating-to-q1-2013-(v-2013-1-319).aspx

Where can we get internal build 2013.1.327 ?

It's not listed when I'm logged into my account as an available internal build.

Rene.
Rosen
Telerik team
 answered on 08 Apr 2013
3 answers
258 views
Hi,

I am just wondering how i can use Kendo.UI MVC Grid to create a custom row template. I can see that it is possible in the Telerik.MVC Grid (http://demos.telerik.com/aspnet-mvc/razor/grid/clientrowtemplate), but can only see column template support in Kendo.

Am i missing something, or is feature possible?

Thanks.
Petur Subev
Telerik team
 answered on 08 Apr 2013
3 answers
154 views
I have managed to further pinpoint the issue I'm having with 2013.1.401.

It seems to only occur when I have nested grids (grid with popup edit with child grid):

a) parent grid with popup edit window (A)
b) popup edit window (A) from a contains a child grid (child grid also has popup edit window(B)).
c) upon closing the popup edit window A - not matter if I edited/updated/created or just closed the window - it faults out in kendo.all.js in the grid destroy for the child grid.  The first error occurs at the that.resizable.destroy(); below:  ( I have verified the error occurs  on the child grid destroy).

Basically - this is reproducible for all grids with popup edit windows with child grids on those popup edit windows.

destroy: function() {
            //alert('destroying grid?');
            var that = this,
                element;

            Widget.fn.destroy.call(that);

            if (that.pager) {
                that.pager.destroy();
            }

            if (that.groupable) {
                that.groupable.destroy();
            }

            if (that.options.reorderable) {
                that.wrapper.data("kendoReorderable").destroy();
            }

            if (that.resizable) {
                that.resizable.destroy();
            }
Vladimir Iliev
Telerik team
 answered on 08 Apr 2013
5 answers
1.2K+ views
I am still new to MVC and still trying to get a grasp on the best way to do things.  I realize at some point I'll probably need to switch to using Repositories or something but for now I have my EF Models and I am trying to use ViewModels in my Controllers.

I am trying to display a Grid and perform basic CRUD operations.  I am using an EditorTemplate for the popup mode.  Basically the Grid is supposed to  display a set of items (Beamlines).  One of the fields within a Beamline is an AllocationPanelID.  The Beamline stores the AllocationPanelID but the full list of AllocationPanels is in a separate model.  So my understanding of ViewModels is that I can combine data from multiple models into one View Model.  This is where I am having trouble.  I define that AllocationPanel IEnumerable<SelectListItem> in the View Model and connect it in the Controller but when it gets to it in the
View it has NULL as if it is never really getting hooked up to the data.

View Model: (shortened for breviety)
public class BeamlineViewModel
{
    public decimal ID { get; set; }
    public string Description { get; set; }
    public Nullable<decimal> SortOrder { get; set; }
    public string InsertionDevice { get; set; }
    public Nullable<decimal> AllocationPanelID { get; set; }
    public string Status { get; set; }
 
    public IEnumerable<SelectListItem> AllocationPanels { get; set; }
 
    public IEnumerable<SelectListItem> StatusTypes = new List<SelectListItem>
    {
        new SelectListItem {Value = "A", Text = "Available"},
        new SelectListItem {Value = "C", Text = "Construction and Commissioning"},
        new SelectListItem {Value = "D", Text = "Diagnostic and Instrumentation"},
        new SelectListItem {Value = "O", Text = "Operational"},
        new SelectListItem {Value = "U", Text = "Unused Port"}
    };
}

Controller: (only showing Index, Edit, and related methods)
public ActionResult Index()
{
    return View(GetBeamlines());
}
 
public ActionResult Edit(int id)
{
    using (MyEntities context = new MyEntities())
    {
        return View(context.Beamlines.Find(id));
    }
}
 
private static IEnumerable<BeamlineViewModel> GetBeamlines()
{
    var context = new MyEntities();
    return context.Beamlines.Select(b => new BeamlineViewModel
    {
        ID = b.ID,
        Description = b.Description,
        SortOrder = b.Sort_Order,
        InsertionDevice = b.Insertion_Device,
        AllocationPanelID = b.Allocation_Panel_ID,
        Status = b.Status
    });
}
 
public ActionResult GetAllocationPanels()
{
    using (MyEntities context = new MyEntities())
    {
        var allocationPanels = context.Allocation_Panels.ToList();
        var model = new BeamlineViewModel
        {
            AllocationPanels = allocationPanels.Select(m => new SelectListItem { Value = m.ID.ToString(), Text = m.Description })
        };
        return View(model);
    }
}

View:
@model IEnumerable<MyProject.ViewModels.BeamlineViewModel>
 
@{
    ViewBag.Title = "Beamlines";
}
 
<h2>Beamlines</h2>
 
@(Html.Kendo().Grid(Model)
    .Name("gvBeamlines"
    .Columns(columns =>
    {
        columns.Command(command => { command.Edit(); }).Width(50);
        columns.Bound(o => o.Description).Width(100);
        columns.Bound(o => o.InsertionDevice).Title("Insertion Device");
        columns.Bound(o => o.Status);
        columns.Bound(o => o.EnergyRange).Title("Energy Range");
        columns.Command(command => { command.Destroy(); }).Width(50);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Beamline").Window(window => window.HtmlAttributes(new { @style = "width:700px;" })))
    .Pageable()
    .Sortable()
    .DataSource(dataSource => dataSource
        .Server()
        .Model(model => model.Id(o => o.ID))
        .Create(create => create.Action("Create", "Beamlines"))
        .Read(read => read.Action("Index", "Beamlines"))
        .Update(update => update.Action("Edit", "Beamlines"))
        .Destroy(destroy => destroy.Action("Delete", "Beamlines"))
    )
)

Editor Template: (shortened for breviety)
@model MyProject.ViewModels.BeamlineViewModel
 
@Html.HiddenFor(model => model.ID)
 
<div class="editor-label">
    @Html.Label("Beamline")
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Description)
    @Html.ValidationMessageFor(model => model.Description)
</div>
 
<div class="editor-label">
    @Html.Label("Status")
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.Status, new SelectList(Model.StatusTypes, "Value", "Text"), "(Select One)")
    @Html.ValidationMessageFor(model => model.Status)
</div>
 
<div class="editor-label">
    @Html.Label("Sort Order")
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.SortOrder)
    @Html.ValidationMessageFor(model => model.SortOrder)
</div>
 
<div class="editor-label">
    @Html.Label("Insertion Device Beamline")
</div>
<div class="editor-field">
    @Html.RadioButtonFor(model => model.InsertionDevice, "Y")
    @Html.Label("Yes")
    @Html.RadioButtonFor(model => model.InsertionDevice, "N")
    @Html.Label("No")
    @Html.ValidationMessageFor(model => model.InsertionDevice)
</div>
 
<div class="editor-label">
    @Html.Label("Allocation Panel")
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.AllocationPanelID, new SelectList(Model.AllocationPanels, "Value", "Text"), "(Select One)")
    @Html.ValidationMessageFor(model => model.AllocationPanelID)
</div>

A lot of this code I got from different places and have manipulated to get it working.  The GetAllocationPanels() method seems to hook the AllocationPanels IEnumerable that is defined in the View Model but I never actually call the GetAllocationPanels() method or see where to call it.

As the code currently exists, the Grid loads and when I try to edit a Beamline I get an error on the second to last line of the Editor Template, the DropDownListFor for the AllocationPanels.  It gives me a ArgumentNullException.  Value cannot be null. Parameter name: items.

I have also read that it might be better to have a View Model for the Beamline which would just contain the fields making up a Beamline, and then a second View Model for the Beamline listing which would have an instantiation for the first View Model and then also the other items like the AllocationPanels.  I have tried that but could never seem to figure out how to type the View and Editor Template and also what should go in the Controller methods.

Any help is greatly appreciated.

The trouble is.
Daniel
Telerik team
 answered on 05 Apr 2013
1 answer
244 views
Is it possible to create a clientrowtemplate with an entity model that includes a complex type of list to display some fields? I've created a server side rowtemplate but when I switch ajax on datasource, it doesn't work. I think it's expected. But how to create a complex template to display collections with ajax as a custom template?
Dimiter Madjarov
Telerik team
 answered on 05 Apr 2013
4 answers
723 views
HI,

   I am working on exploring the grid features of the Kendo UI. I am working on binding the data table to the grid and populating  the data's.
   
I got the sample solution to work on the data table with the grid from the below URL.

URL: http://www.kendoui.com/code-library/mvc/grid/binding-to-datatable.aspx

I am pretty impressed with the Grid View, but when to try to create the  the edit view  mode as INLINE (or ) INCEL in the grid  i am getting the below error.when i try to give the popup in the gridview, I am not getting anything from the data table in popup.

Please suggest me that whether am I trying anything wrong or Kendo UI dosen't support the below functionality.if kendo UI supports this functionality,
 could you please give me the working example ???????

Error:

"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."


Code Used:

@model System.Data.DataTable

@(Html.Kendo().Grid(Model)
    .Name("Grid")    
    .Columns(columns => {
        columns.Command(command => { command.Edit(); }).Width(100).Title("Edit");
        columns.Command(command => { command.Destroy(); }).Width(100).Title("Delete");
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            columns.Bound(column.DataType, column.ColumnName);     
        }
    })    
   .Editable(ed => ed.Mode(GridEditMode.InCell))
   .ToolBar(toolbar =>
            {
                toolbar.Create();               
                toolbar.Save(); 

            })
   .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource        
        .Ajax()
        .Batch(true)
        .Model(model =>{model.Id(OP => OP.Row[0]);
            model.Field(pd => pd.Row[0]).Editable(false);})
        .Create(update => update.Action("EditingInline_Create", "ModelsView"))
        .Read(read => read.Action("Read", "Home"))
        .Update(update => update.Action("EditingInline_Update", "ModelsView"))
        .Destroy(update => update.Action("EditingInline_Destroy", "ModelsView"))    
    )
)

Raju
Top achievements
Rank 1
 answered on 05 Apr 2013
0 answers
207 views
I'm using the Table Per Concrete type where I have all my models inherit from one base class which has common properties. Since the Get, Insert, Update, and Delete methods do the same thing for each model I'm using, I want to make these methods reusable for each of these models.

Here is the code that I currently have:

PhoenixDB ctx = new PhoenixDB();

public ActionResult Index()
{
return View();
}

public ActionResult Get([DataSourceRequest] DataSourceRequest request)
{
return Json(GetViewModels().ToDataSourceResult(request));
}

public ActionResult Update([DataSourceRequest] DataSourceRequest request, Parameter parameter)
{
var parameterToUpdate = ctx.Parameter.First(param => param.ParameterID == parameter.ParameterID);
TryUpdateModel(parameterToUpdate);

ctx.SaveChanges();

return Json(ModelState.ToDataSourceResult());
}

public ActionResult Insert([DataSourceRequest] DataSourceRequest request, Parameter parameterToAdd)
{
if (ModelState.IsValid)
{
ctx.Parameter.Add(parameterToAdd);
ctx.SaveChanges();
}

return Json(new[] { parameterToAdd }.ToDataSourceResult(request));
}

public ActionResult Delete([DataSourceRequest] DataSourceRequest request, Parameter parameter)
{
var parameterToDelete = ctx.Parameter.First(param => param.ParameterID == parameter.ParameterID);

if (parameterToDelete != null)
{
ctx.Parameter.Remove(parameterToDelete);
ctx.SaveChanges();
}

return Json(new[] { parameterToDelete }.ToDataSourceResult(request));
}

private IQueryable<Parameter> GetViewModels()
{
return (from parameter in ctx.Parameter select parameter);
}

Here is something I would like to do to make it generic, but not sure how:

public ActionResult Update([DataSourceRequest] DataSourceRequest request, Base base)
{
var baseToUpdate = ctx.Base.First(param => param.ParameterID == base.ParameterID);
TryUpdateModel(baseToUpdate);

ctx.SaveChanges();

return Json(ModelState.ToDataSourceResult());
}

Any help with this would be greatly appreciated.
Greg
Top achievements
Rank 1
 asked on 05 Apr 2013
1 answer
1.2K+ views
In Kendo Grid, How to automatically adjust the column width on the basis of the column data length and browser window width
Dimiter Madjarov
Telerik team
 answered on 05 Apr 2013
0 answers
182 views
I am starting a new project and was going to use KendoUI for it.
But there it does not have any docking functionality.
Whereas the telerik ASP.NET Ajax controls do.

Now i am wondering if i should not just use those instead.
But before i make a decision i would love some input on this.
What are the advantages and disadvantages of both?

In what cases would one work better over the other?
Andrew
Top achievements
Rank 1
 asked on 05 Apr 2013
2 answers
58 views
Hi Guys,
I was trying to follow your instructions, downloaded couple test projects from this forum, but I cannot make ComboBox show up without error unfortunately. The error is attached as image.  

Unfortunately I cannot attach project archive here, its 3.2 MB. You can find the archive here:
https://mega.co.nz/#!iVBERZBS!GxynyTs87MJHuzOub4VoBw4iSSUmDv7cOxP3ml0kp

Can you please take a look, I was just trying to show simple ComboBox on /Home/Index.cshtml

Thank you in advance!
sta
Top achievements
Rank 1
 answered on 05 Apr 2013
Narrow your results
Selected tags
Tags
+133 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?