Telerik Forums
UI for ASP.NET MVC Forum
3 answers
266 views
Our system is multi-language, but localization for grids was only working to English.Then, we added Kendo.Mvc.resources.dll to our projects, but then, grids buttons/messages/etc are only in English and this other language.

How can make it work to more languages?

we have this configured:
<% var culture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString(); %>
<script src="<%= this.ResolveUrl("~/Scripts/kendo/2014.2.903/cultures/kendo.culture." + culture + ".min.js") %>" type="text/javascript"></script>
<script type="text/javascript">
    kendo.culture("<%= culture %>");
</script>


Thanks
Vladimir Iliev
Telerik team
 answered on 18 Sep 2014
5 answers
253 views
I'm stumped.

I am trying to use Ajax batch editing, but when I go to save changes with a new record, the grid doesn't display the proper json data that is returned.

Here are a few screenshots to show what's happening:

Add a couple records in one batch, this seems to work great.


Now, if I try and add another record here is what happens:


It has posted to the database just fine.  I have a new line item with Id #35, part id #3, qty 3, and unit price 3, but instead it has duplicated the top record from the grid before the second posting.

Here's the raw json that was returned from the create method:


So, I don't know what I'm missing.  I've poked around but can't seem to pinpoint what is wrong.

Here is my view code:
@(Html.Kendo().Grid<PoLineItemModel>().Name("grdPoLines")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(m => m.Id))
            .Batch(true)
            .ServerOperation(false)
            .PageSize(20)
            .Events(events =>
            {
                events.RequestEnd("onRequestEnd");
                events.Change("onRequestEnd");
            })
            .Create(create => create.Action("Ajax_CreatePoLines","PoHeaders", new { poid = Model.Id}))
            .Read(read => read.Action("Ajax_ReadPoLines", "PoHeaders", new { poid = Model.Id }))
            .Update(update => update.Action("Ajax_UpdatePoLines", "PoHeaders", new { poid = Model.Id }))
            )
        .Columns(columns =>
        {
            columns.Bound(m => m.PoHeaderId).Visible(false);
            columns.Bound(m => m.Id);
            columns.Bound(m => m.PartId);
            columns.Bound(m => m.Quantity);
            columns.Bound(m => m.UnitPrice);
        })
        .ToolBar(toolbar =>
        {
            toolbar.Save();
            toolbar.Create();
        })
        .Navigatable()
        .Sortable()
        .Filterable()
        .Groupable()
        .Editable(edit => edit.Mode(GridEditMode.InCell))
)




Here is my controller method:


public ActionResult Ajax_CreatePoLines([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<PoLineItemModel> poItems)
{
    var poid = Int32.Parse(Request.QueryString["poid"]);
    var ldb = new ShopTrackEntities();
 
    foreach (var newitem in poItems)
    {
        var newline = new PoLine
        {
            PoHeaderId = poid,
            PartId = newitem.PartId,
            Quantity = newitem.Quantity,
            UnitPrice = newitem.UnitPrice
        };
        ldb.PoLines.Add(newline);
    }
    ldb.SaveChanges();
 
    var allitems = GetPoLineItems(poid);
    var lines = new List<PoLineItemModel>();
 
    foreach (var item in allitems)
    {
        var additem = new PoLineItemModel
        {
            Id = item.Id,
            PoHeaderId = item.PoHeaderId,
            PartId = (int)item.PartId,
            Quantity = (int)item.Quantity,
            UnitPrice = (decimal)item.UnitPrice
        };
        lines.Add(additem);
    }
 
    return Json(lines.ToDataSourceResult(request,ModelState));
 
 
}

Any thoughts?

Thanks,
-Sid.
Sid
Top achievements
Rank 1
 answered on 17 Sep 2014
4 answers
130 views
Hi,

First off; it's absolutelty GREAT that you've released server wrappers for use with mobile! Up until now, I've made my own "homerolled" asp.net mobile application using javascript and different views with mvc. (Quite the hassle!)

Now, I've finally decided to port it over to your new server wrappers, and that's where I need some help!
I see from your demos that you include a
@{   
    Layout = "~/Areas/razor/Views/Shared/_MobileLayout.cshtml";
}
in all of your examples. What does this layout contain? For me, the examples doesn't really do me much good if I do not know how to setup my layout properly. The reason for my asking is that I have two shared layouts; one for logged in users and one for users that has not logged in yet.

My "_AnonynmousUserLayout.cshtml" (razor) looks like this:
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link href="~/Content/kendo/2013.2.716/kendo.common.min.css" rel="stylesheet"/>
        <link href="~/Content/kendo/2013.2.716/kendo.default.min.css" rel="stylesheet"/>
        <link href="~/Content/kendo/2013.2.716/kendo.mobile.flat.min.css"/ rel="stylesheet">
         
        <script src="~/Scripts/kendo/2013.2.716/jquery.min.js"></script>
        <script src="~/Scripts/kendo/2013.2.716/kendo.all.min.js"></script>
    </head>
    <body>
        @RenderBody()
    </body>
</html>
And the @RenderBody() will render the Login page, that at the moment looks like this (until I get the wrappers to work):
@(Html.Kendo().MobileView()
        .Name("loginView")
        .Title("Stimline Mobile")
        .Content(
            @<text>
                    <h2>New login form goes here</h2>
                 </text>
           )
      )
When I open the page, nothing is displayed, but if I view the page source (in browser), all the markup including the text is there and produced by the wrappers.
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link href="/Content/kendo/2013.2.716/kendo.common.min.css" rel="stylesheet"/>
        <link href="/Content/kendo/2013.2.716/kendo.default.min.css" rel="stylesheet"/>
        <link href="/Content/kendo/2013.2.716/kendo.mobile.flat.min.css"/ rel="stylesheet">
         
        <script src="/Scripts/kendo/2013.2.716/jquery.min.js"></script>
        <script src="/Scripts/kendo/2013.2.716/kendo.all.min.js"></script>
    </head>
    <body>
         
 
 
        <div data-reload="false" data-role="view" data-stretch="false" data-title="Stimline Mobile" data-use-native-scrolling="false" data-zoom="false" id="loginView"><div data-role="content">
            <h2>New login form goes here</h2>    
        </div></div>
 
 
 
    </body>
</html>
A little help would be appreciated :)

Also, do you have a template for creating a new asp.net mvc mobile project available? Couldn't seem to find one :)
Ruud
Top achievements
Rank 1
 answered on 17 Sep 2014
1 answer
135 views
Hi ,

I have a  one tab strip control and binding dynamically. now i want to generate one grid on tab selection which will get the data by using id of tab node.

How to implement above functionality ?

Thanks in advance

Uday
Dimiter Madjarov
Telerik team
 answered on 17 Sep 2014
11 answers
111 views

Ive opened a bug ticket (856347) for the below problem. Previous versions are fine (2014.2.801 was the last that I was using)

Here it is again just in case any one else has found this happening when updating to SP1 (2014.2.903)...
Javascript error: "Error: Invalid template:'<div class="k-widget k-grid" id="InnerGrid"> ..."

The client detail templates's client template is invalid. Here is a simple demo:

@(Html.Kendo()
    .Grid<TestFilterTemplate.Models.Model>()
    .Name("MainGrid")
    .Columns(cols => {
        cols.Bound(e => e.Id);
        cols.Bound(e => e.Name);
    })
    .ClientDetailTemplateId("testtemplate")
    .DataSource(data => {
        data.Ajax().Read(read => read.Action("ListA", "Value"));
    })
)
 
<script type="text/html" id="testtemplate">
@(Html.Kendo()
    .Grid<TestFilterTemplate.Models.Model>()
    .Name("InnerGrid")
    .Filterable() //<--- remove me and i work.
    .Columns(cols => {
        cols.Bound(e => e.Id);
        cols.Bound(e => e.Name); 
    })
    .DataSource(data => {
        data.Ajax().Read(read => read.Action("ListA", "Value"));
    }).ToClientTemplate()
)
</script>

Removing the .Filterable() line from the client template appears to resolve the problem, but not quite the fix that is needed.

Thanks,
Matt

Dimiter Madjarov
Telerik team
 answered on 17 Sep 2014
1 answer
2.2K+ views
Hi telerik Members:

step1:  I had added    @(Html.Kendo().Editor().name("editor") in view

step2:  I want to set value to editor,  but   $("#editor").val("XXX")  is not work.

step3:  I had found the paper : http://www.telerik.com/forums/empty-editor-by-jquery-628e7aaaa9af, 
            var editor = $("#editor").data("kendoEditor");
            editor.value('');  

           But It is not work too.


Is there some way can set value to editor?    

thank you. 

CUID : QD1612651




Dimiter Madjarov
Telerik team
 answered on 16 Sep 2014
1 answer
115 views
after upgrading to latest version of kendo asp.net mvc 2014.2.903, it is making javascript error "Invalid Template".
It is observed that error occurs if hierarchical grid is filterable, for testing here is the sample code take from the example, i have changed this code to make sub grid as Filterable


@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(e => e.FirstName).Width(110);
            columns.Bound(e => e.LastName).Width(110);
            columns.Bound(e => e.Country).Width(110);
            columns.Bound(e => e.City).Width(110);
            columns.Bound(e => e.Title);
           
        })               
        .Sortable()
        .Pageable()
        .Scrollable()
        .ClientDetailTemplateId("template")
        .HtmlAttributes(new { style = "height:430px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(6)
            .Read(read => read.Action("HierarchyBinding_Employees", "Grid"))            
        )        
        .Events(events => events.DataBound("dataBound"))
)

<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
            .Name("grid_#=EmployeeID#")
            .Columns(columns =>
            {
                columns.Bound(o => o.OrderID).Width(70);
                columns.Bound(o => o.ShipCountry).Width(110);
                columns.Bound(o => o.ShipAddress);
                columns.Bound(o => o.ShipName).Width(200);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
            )
            .Pageable()
            .Sortable()
            .Filterable()
            .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
Dimiter Madjarov
Telerik team
 answered on 16 Sep 2014
6 answers
756 views
I am trying to calculate days interval(finish date - start date) and draw it with Kendo Chart.

My categories are like that:0-5 days; 6-10 days; 11-15 days; 16-20 days;...; Bigger than 30I

n my model, I have timespan day values, and string category names(0-5 days; 6-10 days; 11-15 days; 16-20 days).

model => model.zerotofivevalues = 3, 2 , 4 , 1
model => model.zerotofive = "0-5, "0-5", "0-5"

How can i remove blue prints at my attached picture and "null" ? I think, i have a problem with categorisation but i can't solve this problem.Here is my code:


@(Html.Kendo().Chart(Model)
.Name("chart")
.Series(series =>
{
series
.Column(model => model.zerotofivevalues, categoryExpression: model => model.zerotofive)
.Aggregate(ChartSeriesAggregate.Sum);

series
.Column(model => model.fivetotenvalues, categoryExpression: model => model.fivetoten)
.Aggregate(ChartSeriesAggregate.Sum);


series
.Column(model => model.tentofifteenvalues, categoryExpression: model => model.tentofifteen)
.Aggregate(ChartSeriesAggregate.Sum);

etc, etc, etc,


.CategoryAxis(axis => axis
.Categories("0-5", "5-10", "10-15", "15-20", "20-25")
.MajorGridLines(lines => lines.Visible(false))
Gokhan
Top achievements
Rank 1
 answered on 16 Sep 2014
1 answer
271 views
Can we have cascaded typeahead textbox instead of ordinary DropDownList in kendo grid? The reason is we want to choose BrandName(string) from database first, if it's not an existing BrandName, we want the ability to enter a new one. Then the choice of Model#(string) would be depending on BrandName. If there is some model# for that brand, we list all of them and let user make a choice. If not, we allow user to enter a new model#.

I tried combobox and autocomplete. Couldn't succeed.

Here is the code that I'm trying (just in case it would be helpful)
                @(Html.Kendo().Grid<mobiCore.Models.ReportDetailModel>()
                .Name("ReportDetail")
                .Columns(columns =>
                {
                    columns.Bound(p => p.BrandName).HeaderHtmlAttributes(new { @title = "Brand Name" }).ClientTemplate("#=BrandName.Name#");
                    columns.Bound(p => p.ModelNo).HeaderHtmlAttributes(new { @title = "Model Number" }).EditorTemplateName("ModelNo");
                    columns.ForeignKey(p => p.ProductID, (SelectList)ViewBag.Product).Title("Product");
                    columns.Bound(p => p.Units).Width(75);
                    columns.Command(command => { command.Destroy(); }).Width(85);
                })
                .ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); })
                .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
                .Pageable()
                .Sortable()
                .Navigatable()
                .Scrollable()
        // .HtmlAttributes(new { style = "maxwidth:1400px;" })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Batch(true)
                    .Events(events => events.Error("error_handler"))
                    .Model(model =>
                    {
                        model.Id(p => p.ReportDetailID);
                        model.Field(p => p.ReportID).Editable(false);
                        model.Field(p => p.Units).DefaultValue(0);
                        model.Field(p => p.ProductID).DefaultValue(0);

                    })
                    .ServerOperation(false)
                    .Read(read => read.Action("Detail_Read", "ReportDetail", new { id = Model.ReportID }))
                    .Create(create => create.Action("Detail_Create", "ReportDetail", new { id = Model.ReportID }))
                    .Update(update => update.Action("Detail_Update", "ReportDetail"))
                    .Destroy(delete => delete.Action("Detail_Destroy", "ReportDetail"))
                )
            )
 <script type="text/javascript">


    function filterBrand() {
        return {
            CompanyID: '@Model.CompanyID'
        };
    }
    function filterModel() {
        return {
            CompanyID: '@Model.CompanyID',
            BrandName: $("#BrandName").data("AutoComplete").value()
        };
    }
</script>

Below is partial view under EditorTemplates: BrandName.schtml
@model string

@(Html.Kendo().AutoComplete()
    .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(""))
    .DataTextField("Name")
     .DataSource(dataSource => dataSource.Read(read => read.Action("GetBrand", "CustomerUnitReports").Data("filterBrand")).ServerFiltering(true))
    .HtmlAttributes(new { @class = "k-widget k-autocomplete k-input", style = string.Format("width:200px") })
    .Delay(500)
    .HighlightFirst(true)
)  

Below is partial view under EditorTemplates: ModelNo.schtml
@model string

@(Html.Kendo().ComboBoxFor(m => m)
                  .AutoBind(false)
                          .Placeholder("Select Model#...")
                                  .DataTextField("ModelNumber")
                              .DataValueField("ModelNumber")
                  .DataSource(dataSource =>
                  {
                      dataSource.Read(read => read.Action("GetModelNo", "CustomerUnitReports").Data("filterModel"))
                                .ServerFiltering(true);
                  })
                  .CascadeFrom("BrandName")
)


@Html.ValidationMessageFor(m => m)

Thanks a lot,
Petur Subev
Telerik team
 answered on 15 Sep 2014
1 answer
259 views
Hi,
   
  I am using below code to display Kendo Grid inside Kendo TabStrip. Here GetDetails is a JsonResult method in controller returning different data based on each tab selection.Each selected tab name is sent as parameter to Grid ,based on that , data is binded to Grid.According to our requirement , We have tabstrip where tabs are loaded dynamically . Inside of this tabstrip, we have Kendo grid. Based on tab selection we need to display different data in kendo grid present inside tabstip.Grid inside tabstrip may have different column names based on tab selection.Suppose if user click on First tab,then that value is sent to JsonResult method in controller to retrieve  data and if obtained data has only 2 columns like Name,Title  then only  those 2 columns should be displayed in grid. If user click on Second tab,then that value is sent to JsonResult method in controller to retrieve  data and if obtained data has only 5 columns like Name,Location,City,Address,Status then only  those 5 columns should be displayed in grid.

     With below code, i am getting same column names for all tab grids.For each tab selection , same column names are binded to all grids.How can i bind different column names to gird present in each tab.Column names in grid should  change for each tab selection based on data obtained from GetDetails is a JsonResult method in controller.

@(Html.Kendo().TabStrip()
    .Name("tabstrip") 
       
          .Items(tabstrip =>
          {
             foreach (var tab in @Model)
              {
                   tabstrip.Add().Text(tab.ComponentTypes).Content(@<text>
            @(Html.Kendo().Grid<Portal.Entity.ComponentProperty>().Name("grids" + tab.ComponentTypes)
                //+ DateTime.Now.ToString().Replace(" ", ""))
        .Columns(columns =>
        {
 
        }) .HtmlAttributes(new { style = "width: 980px;height: 800px" })
                .Scrollable().Sortable().Pageable().DataSource(dataSource => dataSource
                                .Ajax()
                                  .Read(read => read.Action("GetDetails", "ComponentProperties", new { PropertyName = tab.ComponentTypes }  ))
                                        .ServerOperation(false)      ))
                </text>                       
                );
              }
             
          })
Daniel
Telerik team
 answered on 15 Sep 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
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
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?