Telerik Forums
UI for ASP.NET MVC Forum
2 answers
316 views

I am using Kendo UI for ASP.Net MVC 2015.2.   I have defined a grid using razor syntax as follows:

 

                                                                Html.Kendo().Grid(Of NameValue)() _
                                                                .Name("grdTerms") _
                                                                .DataSource(Function(ds) ds.Ajax() _
                                                                .Batch(True) _
                                                                .ServerOperation(False) _
                                                                .Read(Function(r) r.Data(UIHelper.ToJSON(Model.MyNameValues)))) _
                                                                .Columns(Sub(c)
                                                                             c.Bound("Name").Title("My Name")
                                                                             c.Bound("Value").Title("My Value")
                                                                         End Sub) _
                                                                .Pageable(Function(pager) pager.Input(True).Numeric(False).Info(True).PreviousNext(True).Refresh(True).PageSizes(True)) _
                                                                .Scrollable() _
                                                                .Render()

 

The generated JQuery for the grid in the view shows that the datasource has JSON data assigned, yet no data appears in the grid.  The view code is generated as follows:

 

<div class="k-widget k-grid" id="grdTerms"><div class="k-grid-header"><div class="k-grid-header-wrap"><table><colgroup><col /><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-field="Name" data-index="0" data-title="My Name" scope="col"><span class="k-link">My Name</span></th><th class="k-header" data-field="Value" data-index="1" data-title="My Value" scope="col"><span class="k-link">My Value</span></th></tr></thead></table></div></div><div class="k-grid-content" style="height:200px"><table><colgroup><col /><col /></colgroup><tbody><tr class="k-no-data"><td colspan="2"></td></tr></tbody></table></div><div class="k-pager-wrap k-grid-pager"><a class="k-link k-pager-nav k-state-disabled k-pager-first" data-page="1" href="#" title="Go to the first page"><span class="k-icon k-i-seek-w">seek-w</span></a><a class="k-link k-pager-nav k-state-disabled" data-page="0" href="#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><span class="k-pager-input k-label">Page<input class="k-textbox" type="text" value="1" />of 1</span><a class="k-link k-pager-nav k-state-disabled" data-page="2" href="#" title="Go to the next page"><span class="k-icon k-i-arrow-e">arrow-e</span></a><a class="k-link k-pager-nav k-state-disabled k-pager-last" data-page="1" href="#" title="Go to the last page"><span class="k-icon k-i-seek-e">seek-e</span></a><span class="k-pager-sizes k-label"><select><option>5</option><option>10</option><option>20</option></select>items per page</span><a class="k-pager-refresh k-link" href="/Test/Test" title="Refresh"><span class="k-icon k-i-refresh">Refresh</span></a><span class="k-pager-info k-label">No items to display</span></div></div><script>
jQuery(function(){jQuery("#grdTerms").kendoGrid({"columns":[{"title":"My Name","field":"Name","encoded":true},{"title":"My Value","field":"Value","encoded":true}],"pageable":{"input":true,"numeric":false,"refresh":true,"pageSizes":[5,10,20],"buttonCount":10},"messages":{"noRecords":"No records available."},"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":"","data":[{"Name":"Test 1","Value":"1","Tag":""},{"Name":"Test 2","Value":"2","Tag":""},{"Name":"Test 3","Value":"3","Tag":""}]},"prefix":""},"pageSize":10,"page":1,"total":0,"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"Value":{"type":"object"},"Tag":{"type":"string"},"Name":{"type":"string"},"Dirty":{"type":"boolean"},"SupressEvents":{"type":"boolean"}}}},"batch":true}});});
</script>

 

As can be seen, the dataSource has data assigned - "data":[{"Name":"Test 1","Value":"1","Tag":""}, .... yet the grid renders empty.

What am I missing?

 

 

Rosen
Telerik team
 answered on 01 Jul 2015
1 answer
89 views
I have a menu that I want to add tooltips to. So far, I have added a tooltip, but it is for the entire menu and I would like different tooltips for each menu item.

Is this possible and if so, how would I do it?

Here is the code I have so far:
<div style="background-color: #41526e; float: left">
    @(Html.Kendo()
          .Menu()
          .Name("Menu")
          .Items(items =>
          {
              items.Add().Text("Home").Action("Index", "Home").ImageUrl(Url.Content("~/Images/Home.png"));
              items.Add().Separator(true);
              items.Add()
                   .Text("Search")
                   .Action("Search", "Catalog")
                   .ImageUrl(Url.Content("~/Images/Search.png"));
              items.Add().Separator(true);
              items.Add()
                   .Text("First Action")
                   .Action("FirstAction", "Catalog")
                   .ImageUrl(Url.Content("~/Images/Promote.png"));
              items.Add().Separator(true);
              items.Add()
                   .Text("Second Action")
                   .Action("SecondAction", "Catalog")
                   .ImageUrl(Url.Content("~/Images/Promote.png"));
              items.Add().Separator(true);
              items.Add()
                   .Text("Subscription Stuff")
                   .Action("Index", "Subscription");
              items.Add().Separator(true);
              items.Add()
                   .Text("Schedule Stuff")
                   .Action("CreateSchedule", "Subscription");
          })
          .Orientation(MenuOrientation.Vertical)
    )
 
    @(Html.Kendo()
        .Tooltip()
        .For("#Menu")
        //.Filter("button")
        .AutoHide(true)
        .Content("Greetings, Puny Earthling! This is a tooltip for your edification.")
        .Position(TooltipPosition.Top)
        .Width(200)
    )
 
</div>

 

TIA,

Bob

Iliana Dyankova
Telerik team
 answered on 01 Jul 2015
4 answers
854 views

Hello,

 we are trying to export a Grid to Excel. This works fine, but since we are using percentage based width for some columns, this percentage ("30%") gets turned into a pixel count (30px), which in turn makes the Excel column way too small.

 

Is there a way to set a better width, or an automatic "Be as big as you need to be in Excel" for the export?

 

@(Html.Kendo().Grid<BusinessObjectLayer.BusinessObjects.CategoryOfCostBusinessObject>()
    .Name("CategoryGrid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Title).Width("30%");
        columns.Bound(p => p.Rate).Width(70);
        columns.Bound(p => p.Description).ClientTemplate("#: convertHtmlString(Description, 50)#");
        columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(88);
    })
    .ToolBar(toolbar => { toolbar.Create().Text("Add Category"); toolbar.Excel().HtmlAttributes(new { @class = "pull-right" }).Text(" Export to Excel"); })
    .Excel(excel => excel
        .FileName("Categories.xlsx")
        .Filterable(true)
        .AllPages(true)
        .ProxyURL(Url.Action("ExcelExport", "Category"))
    )

Thanks for your help,

Klaus

Dimiter Madjarov
Telerik team
 answered on 01 Jul 2015
1 answer
259 views

Hi,

i'm using Kendo.Mvc version 2015.1.429.440 (Q2 2015), but when I use Locked(true) to a column,

it doesn't get frozen. I'd like to know:

- what is doing wrong in my code

@(Html.Kendo().Grid(Model)
         .Name("grid")
                 .Columns(columns =>
                     {
                         columns.Bound(typeof(string), Model.Columns[0].ColumnName.ToString()).Locked(true);
                         
                         for(int p=1;  p< Model.Columns.Count-1; p++)
                         {
                             columns.Bound(typeof(string), Model.Columns[p].ColumnName.ToString())
                                 .Width(150)
                                 .Encoded(false);
                                 //.ClientTemplate("<img src='" + Url.Content(column.ColumnName.ToString()) + "' />")
                         }
                     })                   
        )

 

thanks for help in advance.

Radoslav
Telerik team
 answered on 01 Jul 2015
1 answer
1.3K+ views

Hi team,

 How to change kendo grid property  using jquery. i want change property of kendo Grid. 

if (Some condition)

{

        var grid = $("#GridGlobalNewRequest").data("kendoGrid");
        grid.dataSource.options.schema.model.fields.StartCompany.editable = true;
        grid.dataSource.options.schema.model.fields.IsRead.editable = true;

}

else

{

         var grid = $("#GridGlobalNewRequest").data("kendoGrid");

        grid.dataSource.options.schema.model.fields.StartCompany.editable = false;

        grid.dataSource.options.schema.model.fields.StartCompany.defaultValue = "9990"; // Default Value

}

 

Thanks

Senthilkumar N

Boyan Dimitrov
Telerik team
 answered on 01 Jul 2015
3 answers
542 views

Hi

How do insert a control within a Panel.

As an example below with the Panel Getting Started I would have the text "Testing" and then a Kendo.button underneath ?

 

<h3>Telerik UI for ASP.NET MVC PanelBar</h3>
<br />
 
@(Html.Kendo().PanelBar()
    .Name("IntroPanelBar")
    .Items(items =>
    {
        items.Add()
            .Text("Getting Started")
            .Selected(true)
            .Expanded(true)
            .Content(@<text>
                Testing

    //button here

            </text>);
 
        items.Add()
            .Text("Add NuGet packages and jump-start your coding")
            .Content(@<text>
                <p style="padding:0 1em">NuGet makes it easy to install and update free libraries and tools.
                <a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a></p>
            </text>);
        items.Add()
            .Text("Find Web Hosting")
            .Content(@<text>
                <p style="padding:0 1em">You can easily find a web hosting company that offers the right mix of features
                and price for your applications.
                <a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a></p>
            </text>);
    })
)

 

​

​

Alexander Popov
Telerik team
 answered on 30 Jun 2015
1 answer
130 views

dear community,

 I'm facing the following issue right now:

 within my TreeView it should be possible, that every node and all its children can be copied within the same tree. Therefore I've setup a button which calls a function that tries to copy the node + its children.

The function looks like this:

function CopyTreeViewItems() {
        var treeview = $('#treeview').data('kendoTreeView');
        var selectedNode = treeview.select();
 
        var data = treeview.dataItem(selectedNode);
 
        var newData = {
            id: GenerateGuid(),
            Name: data.Name + "tmp"
        };
 
        treeview.insertAfter(newData, selectedNode);
        var parentItem = treeview.dataItem(treeview.findByText(newData.Name)); //<--- this part is returning 'undefined'
 
            if (data.hasChildren) {
                var children = data.children.data();
 
                for (var i = 0; i < children.length; i++) {
                    var add = { id: GenerateGuid(), Name: children[i].Name };
                    treeview.append(add, parentItem);
                }
            }
}

The parent node is copied without any problems. If there are children of a parent node I'm not able to append them to the corresponding new parent.

Any advices?

Kind regards

Tom

Thomas
Top achievements
Rank 2
 answered on 30 Jun 2015
16 answers
2.0K+ views
Dear Telerik Team!
I've got an essential problem updating a decimal value in a grid.

The model property is annotated wird a weight datatype attribute


        [DataType("Weight")]
        public decimal WeightGross { get; set; }

And the Editortemplate for weight is this:

"
model decimal

@(Html.Kendo().NumericTextBoxFor(m => m)
      .Spinners(false)
)
"

The Problem ist the following: When the culture ist set to "de-DE" the value cannot be correctly updated. The decimal separator is ignored!
If I edit the grid row and enter e.g. '3,25' following happens:
- If I press Tab to go to the next colum the value is correctly shown as '3,25'
- But If I click Update, the value submitted to the controller is 325!

I think this has s.th. to do with the fact that the decimal separator is ',' and not '.' with "de" culture.
If I change the culture to "en" and use '.' as decimal separator it works.
Am I missing s.th or is this a bug in the framework?

brgds
Malcolm Howlett

p.s. If I omit the Datatype annotation it does not get better:
 - I can use ',' as the decimal separator in edit mode
 - but after moving to the next column the value is displayed with '.' decimal separator
- When submittin the decimal separator is still ignored. 3,25 (3.25) becomes 325.
License
Top achievements
Rank 1
 answered on 29 Jun 2015
4 answers
153 views

Configuration :

Main page with grid, editable.Mode(GridEditMode.PopUp) 

This Popup page also have grid with PopUp mode, last Popup page have Treeview with property .Checkboxes(true) 

This popup windows newer appear. 

To fix the situation have to delete .Checkboxes property  from TreeView . As workaround delete Checkboxes  and use TemplateId with scripted template and .ToClientTemplate for treeview. 

But this situation definitely Kendo ui bug, and have to be fixed

 

Alex Gyoshev
Telerik team
 answered on 29 Jun 2015
4 answers
100 views

Hi,

 

I have a grid inline with two fields "OrigenId" and "DestiID". These fields uses foreignkey and two templates named "GetOrigenOnPlanning" and "GetDestiOnPlanning". Now I explaind to you that I need, the data inside in template will be different in function if user selects update or create. The problem is I don't find a event is traggered before the data are inserted in dropboxlist, I tested with event edit or event push of the datasource object.

 

GRID

 

@(Html.Kendo().Grid<ExpeditionViewModel>()
            .Name("expedition")
            .HtmlAttributes(new { style = "margin-bottom:10px;" })
            .Scrollable()
            .ToolBar(t =>
            {
                if (User.IsInRole("Modify"))
                {
                    t.Create().Text("Afegir Expedicio");
                }
            })
            .Columns(columns =>
            {
                columns.Bound(f => f.ExpeditionID).Width(90);
                columns.Bound(f => f.Data).Width(100);
                columns.ForeignKey(f => f.OrigenID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "Nom").Width(120).EditorTemplateName("GetOrigenOnPlanning");
                columns.ForeignKey(f => f.DestiID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "Nom").Width(120).EditorTemplateName("GetDestiOnPlanning");
                columns.ForeignKey(f => f.VehicleID, (System.Collections.IEnumerable)ViewBag.Vehicles, "VehicleID", "Matricula").Width(110).EditorTemplateName("CustomGridForeignKey");
                columns.ForeignKey(f => f.XoferID, (System.Collections.IEnumerable)ViewBag.Xofers, "PersonID", "Nom").Width(200).EditorTemplateName("CustomGridForeignKey");
                if (User.IsInRole("Modify"))
                {
                    columns.Command(commands =>
                    {
                        commands.Edit();
                        commands.Destroy();
                    });
                }
            })
            .Editable(e => e.Mode(GridEditMode.InLine))
            .Events(e => e
                .Change("onChange")
                .Edit("onEdit")
                )
            .Sortable()
            .Selectable()
            .Pageable(pageable => pageable.Refresh(true))
            .Navigatable()
            .Filterable()
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Model(m =>
                {
                    m.Id(f => f.ExpeditionID);
                    m.Field(f => f.ExpeditionID).Editable(false);
                    m.Field(f => f.Data).DefaultValue(ViewBag.date);
                    //m.Field(f => f.OrigenID).DefaultValue(ViewBag.CentreUsuari);
                    //m.Field(f => f.DestiID).DefaultValue(ViewBag.CentreUsuari);
                })
                .Events(e => e
                    .Error(@<text>
                        function (e) {
                        onError(e, "expedition");
                        }
                    </text>)
                    .Push("onPush")
                )
                .Read("Read", "Planning", new { date = ViewBag.date })
                .Create("Create", "Planning")
                .Update("Update", "Planning")
                .Destroy("Destroy", "Planning")
            )
        )
 
 

TEMPLATES

 

@model object
           
@(
 Html.Kendo().DropDownListFor(m => m)
    .Name("OrigenID")
    .DataTextField("Nom")
    .DataValueField("ContactID")
    .ValuePrimitive(true)
    .AutoBind(true)
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("SearchCentres", "Productors", new { area = "Comercial" }).Data("filterCentres");
        })
        .ServerFiltering(true);
    })
)
 
@model object
 
@(
 Html.Kendo().DropDownListFor(m => m)
    .Name("DestiID")
    .DataTextField("Nom")
    .DataValueField("ContactID")
    .ValuePrimitive(true)
    .AutoBind(true)
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("SearchCentres", "Productors", new { area = "Comercial" }).Data("filterCentres");
        })
        .ServerFiltering(true);
    })
)
function filterCentres() {
         
        return {
            contactCreate : isCreate
        };
    }

Code Event Edit and Push

var isCreate;
    function onPush(e) {
        if (e.type == "update") {
            isCreate = false;
        } else {
            if (e.type == "create")
                isCreate = true;
        }
    }
 
    function onEdit(e) {
 
        if (!e.model.isNew()) {
            isCreate = false;
 
            //$("#expedition tbody [data-role=dropdownlist]").each(function () {
            //    var ddl = $(this).data("kendoDropDownList");
            //    if (ddl) {
            //        ddl.options.optionLabel = ddl.value;
                    //ddl.refresh();
                    //ddl.Value("");
            //    }
            //})
 
        } else {
            isCreate = true;
             
            $("#expedition tbody [data-role=dropdownlist]").each(function () {
                var ddl = $(this).data("kendoDropDownList");
                if (ddl) {
                    ddl.options.optionLabel = "-Select Please-";
                    ddl.refresh();
                    ddl.value("");
                }
            })
        

 

 

Thanks in advance.

 

Xavier de la Rubia.

Xavier
Top achievements
Rank 1
 answered on 29 Jun 2015
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?