Telerik Forums
UI for ASP.NET MVC Forum
2 answers
287 views
We're starting to migrate from Telerik MVC Extensions to  Kendo.
As we have the first master detail grid, we begin creating it the same way as the examples that come with installation of Kendo UI.

Here is my view:
@(Html.Kendo()
      .Grid<ShowResumo>()
      .Name("grid")
      .Columns(columns => {
columns.Bound(e => e.MasterId).Hidden(true);
columns.Bound(e => e.Code).Width(110);
columns.Bound(e => e.Description).Width(110);
columns.Bound(e => e.Date).Width(110);
columns.Bound(e => e.Quantity).Width(110);
columns.Bound(e => e.Type);
            
})              
      .Sortable()
      .Pageable()
      .Scrollable()
      .ClientDetailTemplateId("template")
      .HtmlAttributes(new { style = "height:430px;" })
      .DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("ListResumo", "Transportador"))           
)       
      .Events(events => events.DataBound("dataBound"))
)
 
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo()
          .Grid<ShowDetails>()
          .Name("grid_#=MasterId#")
          .Columns(columns => {
    columns.Bound(o => o.TransportId).Width(70);
    columns.Bound(o => o.TruckId).Width(110);
    columns.Bound(o => o.Driver);
    columns.Bound(o => o.Plate).Width(200);
    })
          .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(5)
    .Read(read => read.Action("ListDetails", "Transportador", new { masterId= "#=MasterId#" }))
    )
          .Pageable()
          .Sortable()
          .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
So, it is just like the example, I already even copied it to try to find anything wrong, but I couldn't.
When I run the application and go to this grid, I get the following error:
IE9
Unhandled exception at line 9, column 6594 in http://localhost:60455/Scripts/kendo/2013.1.319/kendo.all.min.js
 
0x800a139e - Microsoft JScript runtime error: Invalid template:'
<div class="k-widget&#32;k-grid" id="grid_#=MasterId#"><table cellspacing="0">
Chrome
Uncaught Error: Invalid template:' <div class="k-widget k-grid" id="grid_#=MasterId#">
Any help?
Ezequiel
Top achievements
Rank 2
 answered on 10 Apr 2013
7 answers
2.1K+ views
Hello!!!
I have a question!
I use this example:http://www.kendoui.com/code-library/mvc/grid/binding-to-datatable.aspx
Please show on this example how to edit object (row)

and next:
I have Model:
public class ShrinkCoeffModel
    {
        [Display(Name = "thickness")]
        public virtual int Thickness { get; set; }
          
        [Display(Name = "wett")]
        public virtual string[] Wetness { get; set; }
  
        [Display(Name = "coeff")]
        public virtual decimal[] Coeff { get; set; }
    }
and Grid:
@(
 Html.Kendo().Grid(Model)
                .Name("ShrinkCoeff")
                .ToolBar(commands =>
                {
                    commands.Create();
                })
                .Columns(columns =>
                {
                    columns.Bound(o => o.Thickness);
                    for (int i = 0; i < Model.FirstOrDefault().Wetness.Count(); i++)
                    {
                    columns.Bound(o => o.Wetness[i]);
                          
                    }
                    columns.Command(command =>
                    {
                        command.Edit();
                        command.Destroy();
                    }).Width(210).Title("Действия");
                })
                .Editable(editable => editable.TemplateName("Item").Mode(GridEditMode.PopUp))
                .DataSource(dataBinding => dataBinding
                    .Server()
                                                    .Model(model => model.Id(o => o.Thickness))
                                                        .Update("Edit", "ShrinkCoeff")
                                                        .Create("Create", "ShrinkCoeff")
                                                        .Destroy("Delete", "ShrinkCoeff"))
                .Pageable()
                .Sortable()
                .Selectable()
)
Why Grid dosn't want work with array(
How I can this do?
for (int i = 0; i < Model.FirstOrDefault().Wetness.Count(); i++)
                    {
                    columns.Bound(o => o.Wetness[i]);
                           
                    }

Vladimir Iliev
Telerik team
 answered on 10 Apr 2013
3 answers
132 views
Dear KendoUI-Team!
I tried to integrate Kendo UI in our existing ASP.NET MVC 3 application. I carefully followed the instructions I found in the web:
- I added kendo.mvc to the project references
- I added the kendo css files
- I also added the kendo javascript files. I placed them in a subfolder of the Script folder.

"...
<script src="@Url.Content("~/Scripts/kendoui/jquery.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/kendoui/kendo.web.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/kendoui/kendo.aspnetmvc.min.js")" type="text/javascript")"></script>
.."
There are no other jquery script includes!

- I made the described changes in web.config in the views folder. I get code completion for kendo ui in my cshtml files.

BUT:
KendoUI does not work at all. The kendo... (e.G. kendoGrid) methods are not available.
Could yoi give me any further hints to investigate the problem. Her are some points that may help
- I put a breakpoint in the dynamic HTML code in the line where the kendo... function is called. The function is called twice. the first time the kendo... function is available. The second time it is not an the error is raised
- This is how my dynamic HTML looks like:
"
<div class="k-widget k-grid" id="di2"><table cellspacing="0"><colgroup><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-field="Rid" data-title="ItemRid" scope="col"><span class="k-link">ItemRid</span></th></tr></thead><tbody><tr class="t-no-data"><td colspan="1"></td></tr></tbody></table></div><script>
jQuery(function(){jQuery("#di2").kendoGrid({"columns":[{"title":"ItemRid","field":"Rid","filterable":{},"encoded":true}],"scrollable":false,"autoBind":false,"dataSource":{"transport":{"prefix":"di2-","read":{"url":""}},"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-server","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"Rid":{"type":"number"},"ArtNoSupplier":{"type":"string"},"ArtNoClient":{"type":"string"},"ItemCurrency":{"type":"string"},"CommCD":{"type":"string"},"CoPref":{"type":"string"},"Unit":{"type":"string"},"FTLOrigin":{"type":"string"},"DescriptionSupplier":{"type":"string"},"CoPEMs":{"type":"string"},"VersionNr":{"type":"number"},"PosNr":{"type":"number"},"Price":{"type":"number"},"PricePer":{"type":"number"},"WeightGross":{"type":"number"},"WeightPer":{"type":"number"},"PemUndefined":{"type":"boolean"},"NoPem":{"type":"boolean"},"HasEUPref":{"type":"boolean"}}}}}});});
</script>
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadDeclarationItems", "Le")))

)
"

If you need any further information please inform me.

brgds
Sven Weiberg

Daniel
Telerik team
 answered on 10 Apr 2013
1 answer
141 views
I have a Kendo.Grid that remains in edit mode after updating.  The only difference between my code and the demo code (that I can tell) is I'm using a third party ORM.  The demo works fine.  

When/how does the grid know the data is persisted correctly?

Grid in View:

@(Html.Kendo()
    .Grid<Copper.Domain.Entities.EntInventory>()
    .Name("_gridCellInventory")
    .Columns(columns =>
    {
        columns.Bound(c => c.DeviceName);
        columns.Command(cmd => cmd.Edit());
    })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(datasource => datasource
        .Ajax()
        .PageSize(20)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(c => c.InventorySeq))
        .Read(read => read.Action("GetCellInventory", "CellInventory").Data("_gridCellInventoryParameters"))    
        .Update(update => update.Action("UpdateCellInventory", "CellInventory")) 
    )   
)

UpdateCellInventory in Controller:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateCellInventory([DataSourceRequest] DataSourceRequest request, EntInventory inventory)
{
    if (inventory != null && ModelState.IsValid)
    {
        _margoRepository.UpdateInventory(inventory);
 
    }
 
    return Json(ModelState.ToDataSourceResult());
}

Thanks,

Jerry



Dimiter Madjarov
Telerik team
 answered on 10 Apr 2013
1 answer
227 views
This is sort of two questions in one. 

We are using the grid to run an approval service. What we are wondering is if the edit box that appears when you are using Popup editing is customizable? Is there a way we could put only certain fields into it?

Also, is there a way that we could add functionality to have another box popup when a button is pushed that will embed or display a video on YouTube or something similar to that? The URL would be saved in the row that the button is on.

 If you could point us in the right direction for these things, that would be great. Thanks!!
Dimiter Madjarov
Telerik team
 answered on 10 Apr 2013
1 answer
86 views
I've implemented the Filterable() on my grid and the filter icon shows up, but nothing happens when you click on the funnel icon.  I've inspected the element and the difference  between my page and the example page is the funnel has an href='#' on the example page, but mine does not, so it appears something has caused the href to not show up.  My code looks like this...

    @(Html.Kendo().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.ApplicantName);
            columns.Bound(p => p.ParentName);
            columns.Bound(p => p.Grade);
            columns.Bound(p => p.Status)
                .ClientGroupFooterTemplate("Count: #=count#");
            columns.Bound(p => p.HoldHistory).Filterable(false).Sortable(false);
            columns.Bound(p => p.CorrespondenceHistory).Filterable(false).Sortable(false);
            columns.Bound(p => p.Scan).Filterable(false).Sortable(false);
            columns.Bound(p => p.FFPStatus).Filterable(false).Sortable(false);
        })
        .ClientRowTemplate(
            "<tr class='#: TRClass #' role='row'>" +
                "<td role='gridcell'><a target='_blank' href='/en/Reporting/GetReadOnlyApp?id=#: AppId #'>#: ApplicantName #</a></td>" +
                "<td role='gridcell'>#: ParentName #</td>" +
                "<td role='gridcell'>#: Grade #</td>" +
                "<td role='gridcell'>#: Status #</td>" +
                "<td role='gridcell'><a href='\\#' id='holdHistory-#: AppId #'>Hold History</a></td>" +
                "<td role='gridcell'><a href='\\#' id='correspondenceHistory-#: AppId #'>Correspondence History</a></td>" +
                "<td role='gridcell'><a href='' target='_blank' onclick='return ShowAWSDoc(\"#: Scan #\")'>#: ScanDescription #</a></td>" +
                "<td role='gridcell'><a href='' target='_blank' onclick='return ShowAWSDoc(\"#: FFPId #\")'>#: FFPStatus #</a></td>" +
            "</tr>"
        )
        .Groupable()
        .Pageable()
        .Sortable()
        .Filterable()
        .DataSource(datasouce => datasouce
            .Ajax()
            .Aggregates(aggregates =>
            {
                aggregates.Add(p => p.Status).Count();
            })
            .PageSize(20)
            .Read("Applicants_Read", "Reporting", new { programId = ViewBag.ProgramId } ))
    )
Kathryn
Top achievements
Rank 1
 answered on 09 Apr 2013
2 answers
259 views
Hi,

1.  I have a page with a mix of Kendo datetime picker, textboxes, and a grid.

2. The datetime picker and textboxes act as filters for the grid when retrieving the data.

3. If I do change some of the fields to the datetime picker and textboxes to the grid the data will populate correctly.

4.   There's a link to a details page in the grid, if I click on the link I am brought to a details page.

The problem is if I click on the back button in the browser I am returned to the correct page, but the kendo datetime picker field is reset to the default (the textbox values seems to remain). The grid is also filtered to the default datetime.

I do not use the Html.BeginForm() but don't think I need tosince the filter button is called in javascript.

Any help would be appreciated. Thanks.

<span>StartDate
    @(Html.Kendo().DateTimePicker()
        .Value((DateTime)Convert.ToDateTime(ViewBag.StartDate))
        .Name("StartDatePicker")
        .Format("yyyy/MM/dd HH:mm:ss")
        .TimeFormat("HH:mm:ss")
        .HtmlAttributes(new { id = "startDateFilter" })
        )
</span>

<span>EndDate
    @(Html.Kendo().DateTimePicker()
        .Value((DateTime)Convert.ToDateTime(ViewBag.EndDate))
        .Name("EndDatePicker")
        .Format("yyyy/MM/dd HH:mm:ss")
        .TimeFormat("HH:mm:ss")
        .HtmlAttributes(new { id = "endDateFilter" })
    )
</span>

<span>Customer
    @Html.TextBox("Customer", null, new { id = "customerFilter", style = "width:105px" })
</span>

<span>
    <input type="submit" id="filterButton" value="Search" class="button-small"/>
</span>

@(Html.Kendo().Grid<FailureLogSummaryViewModel>()
            .Name("FailureLogSummaryGrid")
            .Columns(column =>
            {
                column.Bound(x => x.Id).Width(90).Template(
                    @<text><a href="@Url.Content("~/Home/Edit/" + item.Id)">@Resources.Global.SummaryGridOpenBookString</a>
                    </text>).ClientTemplate("<a href='" + Url.Content("~/Home/Edit/") + "#= Id #'>Open Log</a>").Title("Open").Sortable(false);
            })
            .DataSource(dataBinding => dataBinding
                .Ajax()
                .PageSize(50)
                .Read(read => read.Action("GetData", "Summary")
                    .Data("getSearchFilters"))
                .Model(model => model.Id(o => o.Id)))
            .Events(e => e
                .DataBound("onGridItemsDatabound"))
            .Pageable(paging => paging.Refresh(true))
)
}

Javascript:
var getSearchFilters = function () {
    return {
        startDateFilter: $('#startDateFilter').val(),
        endDateFilter: $('#endDateFilter').val(),
        customerFilter: $('#customerFilter').val(),
    };
};

$("#filterButton").click(function () {
    $("#FailureLogSummaryGrid").data("kendoGrid").dataSource.read();
});

Code Behind:
    public ActionResult GetData([DataSourceRequest]DataSourceRequest request, 
        string startDateFilter, string endDateFilter,
        string customerFilter)
    {
        ... (get data)
        return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }

 
Petur Subev
Telerik team
 answered on 09 Apr 2013
1 answer
115 views
Is there a way to do a batch update  on the details view on a hierarchy Grid? What I would like to do is have the users expand a column, make changes to all the columns in the details grid and then hit the save button to make the changes. Is there a simple way of doing this?
Vladimir Iliev
Telerik team
 answered on 09 Apr 2013
3 answers
187 views
I've created a panelbar in the Layout:

@(Html.Kendo().Splitter()
            .Name("mainsplitter") //The name of the splitter is mandatory. It specifies the "id" attribute of the widget.
            .Panes(panes =>
            {
                panes.Add().Content(@<text>@Html.Action("_Panelbar")</text>)
                            .Resizable(true)
                            .Size("20%");
                panes.Add().Content(@<text>
                            <section class="content-wrapper main-content clear-fix">
                                @RenderBody()
                            </section>
                            </text>); //Add pane
            })
            )
And a rendersection for the main content, it all goes well, but when I
change the main content Model, the panelbar jumps to the first item.
When I return only the ViewBag, and no Model, the panelbar is keeping
the selected item.
What have I to do for keep always the selected item ?

And in the _PanelbarView:

@model CPMPlanning.Models.CPMModelViewPanel

@( Html.Kendo().PanelBar()
    .Name("PanelBar")  
    .SelectedIndex(Model.ObjectIDSelected)
    .ExpandMode(PanelBarExpandMode.Single)
    .BindTo(Model.ObjectTypes, mappings =>
    {
        mappings.For<CPMPlanning.Models.ObjectTypeView>(binding => binding
                .ItemDataBound((item, objecttype) =>
                {
                    item.Text = objecttype.ObjectTypeDesc;

                })
                .Children(o => o.Objects));
        mappings.For<CPMPlanning.Models.ObjectView>(binding => binding
                .ItemDataBound((item, obj) =>
                {
                    item.Text = obj.ObjectCode;
                    item.Url = Url.Action("Index", "CPMModel", new { id = obj.ObjectID });
                })
            );
    })
)

Bram
Top achievements
Rank 1
 answered on 09 Apr 2013
1 answer
98 views
Hi, we have setup an ajax bound grid using a ClientRowTemplate. We also have virtual scrolling turned on. We noticed that if we make a change to a text box value, then scroll down low enough to make the record disappear, the value in the text field is lost. Is there a way to have these values persist? Will we need to store the data in javascript variables? Are there client-side events that are raised when a row goes out of view so that we can save edits? Any feedback is greatly welcomed. 

Thanks
Vladimir Iliev
Telerik team
 answered on 09 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?