Telerik Forums
Kendo UI for jQuery Forum
2 answers
672 views
We've been trying to figure out how to make the kendo grid dynamic, based on the models data. Then get validation settings from within the model onto the grid for the appropriate columns.

We got the dynamic grid working but cannot figure out how to setup the validations specified by the model. Has anyone done this, or have any ideas on how to do this? 

Here's the partial razor view for this grid.

@(Html.Kendo().Grid<CrossReferenceMapDataViewModel>()
           .Name("MappingGrid")
           .Columns(columns =>
                        {
                            columns.ForeignKey(row => row.DataSource, new SelectList(new[]{
                                                                                            new {text="CPDP",value = "1"},
                                                                                            new {text="GXS",value = "2"},
                                                                                            new {text="Terminal",value = "3"},
                                                                                        }, "value", "text")).Title("Data Source");
 
                            if (@ViewBag.crossReferenceMapColumnsList != null)
                            {
                                foreach (CrossReferenceMapColumnViewModel availableColumn in @ViewBag.crossReferenceMapColumnsList)
                                {
                                    switch (availableColumn.XrefDataColumnName)
                                    {
                                        case "DATA01":
                                            columns.Bound(row => row.Data01).Title(availableColumn.ColumnName + " (" + (availableColumn.Direction.ToString() == "Input" ? "from" : "to") + ")");
                                            break;
                                        case "DATA02":
                                            columns.Bound(row => row.Data02).Title(availableColumn.ColumnName + " (" + (availableColumn.Direction.ToString() == "Input" ? "from" : "to") + ")");
                                            break;
                                        case "DATA03":
                                            columns.Bound(row => row.Data03).Title(availableColumn.ColumnName + " (" + (availableColumn.Direction.ToString() == "Input" ? "from" : "to") + ")");
                                            break;
                                        case "DATA04":
                                            columns.Bound(row => row.Data04).Title(availableColumn.ColumnName + " (" + (availableColumn.Direction.ToString() == "Input" ? "from" : "to") + ")");
                                            break;
                                        case "DATA05":
                                            columns.Bound(row => row.Data05).Title(availableColumn.ColumnName + " (" + (availableColumn.Direction.ToString() == "Input" ? "from" : "to") + ")");
                                            break;
                                    }
                                }
                            }
                            columns.Command(row =>
                                                    {
                                                        if (SecurityHelper.UserCanEdit(UserFeature.CrossReferenceDataMapping, Context))
                                                        {
                                                            row.Edit().HtmlAttributes(new {@name = "btnGridRowEdit"});
                                                        }
                                                        else
                                                        {
                                                            row.Custom("hdnE").HtmlAttributes(new { style = "display:none" });
                                                        }
                                                        if (SecurityHelper.UserCanDelete(UserFeature.CrossReferenceDataMapping, Context))
                                                        {
                                                            row.Destroy().HtmlAttributes(new {@name = "btnGridRowDelete"});
                                                        }
                                                        else
                                                        {
                                                            row.Custom("hdnD").HtmlAttributes(new { style = "display:none" });
                                                        }
                                                    }).Title("Actions");
                        })
           .Pageable()
           .Sortable()
           .Scrollable()
           .AutoBind(false)
           .Filterable()
           .Editable(editable => editable.Mode(GridEditMode.InLine))
           .ToolBar(toolBar =>
                        {
                            if (SecurityHelper.UserCanAdd(UserFeature.CrossReferenceDataMapping, Context))
                            {
                            toolBar.Create()
                                .HtmlAttributes(new { @id = "btnCreateMapping" });
                            }
 
                            toolBar.Custom()
                                .Text("Export To Excel")
                                .HtmlAttributes(new { @id = "btnExport" })
                                .Url(UrlMaker.ToCrossReferenceDataMappingExport());
                        })
           .DataSource(dataSource =>
                       dataSource
                           .Ajax()
                           .Events(e => e.Error("onError"))
                           .Read(reader => reader.Action("Read", "CrossReferenceDataMapping").Data("additionalData"))
                           .Create(reader => reader.Action("Create", "CrossReferenceDataMapping").Data("additionalData"))
                           .Update(reader => reader.Action("Update", "CrossReferenceDataMapping"))
                           .Destroy(reader => reader.Action("Destroy", "CrossReferenceDataMapping"))
 
                           .Model(model => model.Id(row => row.MapDataId))
           )
      )
It's not the most elegant way, but it does the job for now, until we can find a better way. 

So, I'm looking for anyone who has a better on how to create the grid and apply the validation. The model will have a regex expression or a max length to validate against. 
Dan
Top achievements
Rank 1
 answered on 31 Jan 2013
1 answer
233 views
Hi

On clicking of "Remove" button, RemoveFiles method do get fired but "IEnumerable<HttpPostedFileBase> files" returns null value
 However "SaveFiles" works fine.
                      $("#files").kendoUpload({
                                async: {
                                    saveUrl: "Attachment/SaveFiles",
                                    removeUrl: "WebSite/RemoveFiles",
                                    autoUpload: true
                                },
                                upload: function (e) {

                                }
                        }).data("kendoUpload"); 


 public PartialViewResult RemoveFiles(IEnumerable<HttpPostedFileBase> files)
        {
            if (files != null)
            {
                                 ....................................
            }
            return PartialView("");
        }

Am I missing something here.
Dimiter Madjarov
Telerik team
 answered on 31 Jan 2013
9 answers
367 views
On Android mobile devices the click event from the drop down lists popup triggers the click event of controls below the clicked item.

This was resolved for Mac Mobile devices in a previous build 2012.2.710 as "Prevent click events through widget's popup in mobile devices".

Alexander Valchev
Telerik team
 answered on 31 Jan 2013
1 answer
185 views
Hello.

I want to add a PanelBar inside a Menu, because I need expanded/collapsed fields inside the menu
I tried this:

@(Html.Kendo().Menu().Name("Menu")
    .Items(items =>
    {
        items.Add().Text("Products")
        .Items(children =>
        {
            children.Add().Text("Furniture");
        });
        items.Add().Text("Stores")
        .Content(@<text>
                @(Html.Kendo().PanelBar().Name("panelbar").ExpandMode(PanelBarExpandMode.Multiple)
                .HtmlAttributes( new { style = "width: 300px" })
                .Items(panelbar =>
                {
                    panelbar.Add().Text("My TeamMates")
                    .Items(it =>
                    {
                        it.Add().Text("First");
                        it.Add().Text("Second");
                    });
                })
            )
        </text>);
    })
)
But the panel is interpreted as children and his items as inner children.

Many thanks.
Petur Subev
Telerik team
 answered on 31 Jan 2013
1 answer
226 views
We recently force the look of the platform to ios and develop the app on Android.

Sometimes we need to display the loading icon (application loading image and pull to refresh icons) but they are not displayed properly.
A rotating grey square is displayed instead. 

Please advice what can I do to correct this.

Thanks.

BR,
Ralph
Kamen Bundev
Telerik team
 answered on 31 Jan 2013
2 answers
196 views
I am trying to set up a demo using the listview in kendoui and having some issues with it., I have the following code below, and when it runs the first time round. It loads in the first 20 items, but when I click on the button again, the button disappears and nothing happens on the page. Just sits there and does nothing, this code is based on the following.

http://demos.kendoui.com/mobile/listview/press-to-load-more.html

Any help you can give on this would be appreciated.

<%@ Page Title="" Language="C#" MasterPageFile="~/mobile.master" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
 <div data-role="view" data-init="mobileListViewPressToLoadMore" data-title="Patient List">
    <header data-role="header">
        <div data-role="navbar">
            <span data-role="view-title"></span>
            <a data-align="right" data-role="button" class="nav-button" href="#index">Index</a>
        </div>
    </header>
 
    <ul id="load-more"></ul>
</div>
 
<script>
    function mobileListViewPressToLoadMore() {
        var dataSource = new kendo.data.DataSource({
            pageSize: 20,
            serverPaging: true,
            transport: {
                read: {
                    url: "http://myservices/rest/plan.svc/Patient" // the remove service url
                     
                     
                },
 
       parameterMap: function(options) {
                        var parameters = {
                            q: "javascript", //additional parameters sent to the remote service
                            rpp: options.pageSize,
                            page: options.page //next page
                        };
 
                        return parameters;
                    }
                    },  schema: { // describe the result format
                data: "" // the data which the data source will be bound to is in the "results" field
            }
        });
 
        $("#load-more").kendoMobileListView({
            dataSource: dataSource,
            template: $("#load-more-template").text(),
            loadMore: true
        });
 
    }
</script>
 
<script id="load-more-template" type="text/x-kendo-template">
    <div class="tweet">
         
        <div class="metadata">
            <a class="sublink" target="_blank" href="http://#= id #" rel="nofollow">#= first_name + ' ' + last_name #</a>
            |
            <a class="sublink" href="http://#= mrn #" rel="nofollow">#= pat_seqno #</a>
        </div>
    </div>
</script>
 
<style scoped>
    .tweet {
        font-size: .8em;
        line-height: 1.4em;
    }
    .pullImage {
        width: 64px;
        height: 64px;
        border-radius: 3px;
        float: left;
        margin-right: 10px;
    }
    .sublink {
        font-size: .9em;
        font-weight: normal;
        display: inline-block;
        padding: 3px 3px 0 0;
        text-decoration: none;
        opacity: .8;
    }
</style>
 
</asp:Content>
JD
Top achievements
Rank 1
 answered on 31 Jan 2013
3 answers
364 views
I have one tree component, and in one of the columns, depending on the type, I use a date picker. As it's possible to see in the first attachment, the calendar is displayed always in the wrong position.

The top and left properties of the calendar container are wrong, so I was wondering why could it be causing that those values are calculated wrong (because I guess they are calculated when the button to show the calendar is clicked)

Could this be a known issue that was solver in newer versions?

Thanks, 

Kendo UI version: Chrome 24.0.1312.56 

OS: Windows 7
exact browser version: Chrome 24.0.1312.56 
jQuery version (if registered independently from Kendo UI): jQuery v1.8.3

Iliana Dyankova
Telerik team
 answered on 31 Jan 2013
5 answers
433 views
Hi.  I have a kendo grid and am adding a detail template.  This all works fine until I add an edit command to the template.  I then get a 
Uncaught Error: Invalid template:'
Error.

I've put in BOLD the line which is causing the error to occur
I've also included the error underneath (apologies for the length)

Any help would be greatly appreciated!!

UPDATE:  Removing 
columns.Bound(Function(p) p.DeviceRuleID)
columns.Bound(Function(p) p.RulePriority)
from the template (these two fields are int32's) causes the error to disappear.  But i need these fields so this isn't fixed..just hopefully narrowed down

@* Kendo Grid control*@
@(Html.Kendo().Grid(Of Models.Device) _
    .Name("Devices") _
    .HtmlAttributes(New With {.style = "width: 100%", .align = "center"}) _
    .Columns(Function(columns)
                     columns.Bound(Function(p) p.deviceTag).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.DeviceEnabled).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.DeviceDescription).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.ViewSuffix).Groupable(True).Width(200)
                     columns.Command(Function(command)
                                             command.Edit()
                                     End Function).Width(200)
             End Function) _
   .ClientDetailTemplateId("DeviceRuleTemplate") _
    .Editable(Function(editable) editable.Mode(GridEditMode.InLine)) _
    .ToolBar(Function(toolbar) toolbar.Create()) _
    .DataSource(Function(dataSource)
               dataSource.Ajax.Events(Function(events) events.Error("error_handler"))
               dataSource.Ajax.Model(Sub(model)
                              model.Id(Function(p) p.ViewSuffix)
                              model.Field(Function(p)   p.ViewSuffix).Editable(False)
                                 End Sub)
               dataSource.Ajax.Create(Function(create) create.Action("Device_Create", "Device"))
               dataSource.Ajax.Read(Function(read) read.Action("Device_Read", "Device"))
               dataSource.Ajax.Update(Function(update) update.Action("Device_Update", "Device"))
               dataSource.Ajax.Destroy(Function(delete) delete.Action("Device_Delete", "Device"))
                End Function)
    )
     
<script id="DeviceRuleTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid(Of Models.DeviceRule) _
    .Name("Rules_#=deviceTag#") _
    .Pageable() _
    .Columns(Function(columns)
                     columns.Bound(Function(p) p.DeviceRuleID)
                     columns.Bound(Function(p) p.ViewSuffix)
                     columns.Bound(Function(p) p.RuleName)
                     columns.Bound(Function(p) p.RulePriority)
                     columns.Bound(Function(p) p.Active)
                     columns.Command(Function(command)
                                         command.Edit()
                                     End Function).Width(200)
             End Function) _
              .DataSource(Function(dataSource)
                           dataSource.Ajax.Read(Function(read) read.Action("DeviceRules_GetForDevice", "Device", New With {.ViewSuffix = "#=ViewSuffix#"}))
                           dataSource.Ajax.Model(Sub(model)
                                      model.Id(Function(p) p.DeviceRuleID)
                                        End Sub)
                           dataSource.Ajax.Create(Function(create) create.Action("DeviceRule_Create", "Device"))
                           dataSource.Ajax.Update(Function(update) update.Action("DeviceRule_Update", "Device"))
                           dataSource.Ajax.Destroy(Function(delete) delete.Action("DeviceRule_Delete", "Device"))
                      End Function) _
 .ToClientTemplate())
</script>
 
 
@*Script for the error handler of the grid*@
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
  
</script>
Error
Uncaught Error: Invalid template:'
    <div class="k-widget k-grid" id="Rules_#=deviceTag#"><table cellspacing="0"><colgroup><col /><col /><col /><col /><col /><col style="width:200px" /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-field="DeviceRuleID" data-title="Device Rule ID" scope="col"><span class="k-link">Device Rule ID</span></th><th class="k-header" data-field="ViewSuffix" data-title="View Suffix" scope="col"><span class="k-link">View Suffix</span></th><th class="k-header" data-field="RuleName" data-title="Rule Name" scope="col"><span class="k-link">Rule Name</span></th><th class="k-header" data-field="RulePriority" data-title="Rule Priority" scope="col"><span class="k-link">Rule Priority</span></th><th class="k-header" data-field="Active" data-title="Active" scope="col"><span class="k-link">Active</span></th><th class="k-header" scope="col"><span class="k-link"> </span></th></tr></thead><tbody><tr class="t-no-data"><td colspan="6"></td></tr></tbody></table><div class="k-pager-wrap k-grid-pager"><a class="k-link k-state-disabled" 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-state-disabled" data-page="0" href="\#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link 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-state-disabled" 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-info k-label">No items to display</span></div></div><script>
    jQuery(function(){jQuery("\#Rules_#=deviceTag#").kendoGrid({"columns":[{"title":"Device Rule ID","field":"DeviceRuleID","filterable":{},"encoded":true,"editor":"\u003cdiv class=\"t-widget t-numerictextbox\"\u003e\u003cinput class=\"t-input\" data-val=\"true\" data-val-number=\"The field DeviceRuleID must be a number.\" data-val-required=\"The DeviceRuleID field is required.\" id=\"DeviceRuleID\" name=\"DeviceRuleID\" style=\"width:50%\" type=\"text\" value=\"0\" /\u003e\u003ca class=\"t-link t-icon t-arrow-up\" href=\"#\" tabindex=\"-1\" title=\"Increase value\"\u003eIncrement\u003c/a\u003e\u003ca class=\"t-link t-icon t-arrow-down\" href=\"#\" tabindex=\"-1\" title=\"Decrease value\"\u003eDecrement\u003c/a\u003e\u003c/div\u003e\u003cscript type=\"text/javascript\"\u003e\tjQuery(\u0027#DeviceRuleID\u0027).tTextBox({val:0, step:1, minValue:-2147483648, maxValue:2147483647, digits:0, groupSize:3, negative:1, text:\u0027Enter value\u0027, type:\u0027numeric\u0027});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"DeviceRuleID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"View Suffix","field":"ViewSuffix","filterable":{},"encoded":true,"editor":"\u003cinput class=\"text-box single-line\" id=\"ViewSuffix\" name=\"ViewSuffix\" type=\"text\" value=\"\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"ViewSuffix\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Rule Name","field":"RuleName","filterable":{},"encoded":true,"editor":"\u003cinput class=\"text-box single-line\" id=\"RuleName\" name=\"RuleName\" type=\"text\" value=\"\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"RuleName\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Rule Priority","field":"RulePriority","filterable":{},"encoded":true,"editor":"\u003cdiv class=\"t-widget t-numerictextbox\"\u003e\u003cinput class=\"t-input\" data-val=\"true\" data-val-number=\"The field RulePriority must be a number.\" data-val-required=\"The RulePriority field is required.\" id=\"RulePriority\" name=\"RulePriority\" style=\"width:50%\" type=\"text\" value=\"0\" /\u003e\u003ca class=\"t-link t-icon t-arrow-up\" href=\"#\" tabindex=\"-1\" title=\"Increase value\"\u003eIncrement\u003c/a\u003e\u003ca class=\"t-link t-icon t-arrow-down\" href=\"#\" tabindex=\"-1\" title=\"Decrease value\"\u003eDecrement\u003c/a\u003e\u003c/div\u003e\u003cscript type=\"text/javascript\"\u003e\tjQuery(\u0027#RulePriority\u0027).tTextBox({val:0, step:1, minValue:-2147483648, maxValue:2147483647, digits:0, groupSize:3, negative:1, text:\u0027Enter value\u0027, type:\u0027numeric\u0027});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"RulePriority\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Active","field":"Active","filterable":{},"encoded":true,"editor":"\u003cinput class=\"check-box\" data-val=\"true\" data-val-required=\"The Active field is required.\" id=\"Active\" name=\"Active\" type=\"checkbox\" value=\"true\" /\u003e\u003cinput name=\"Active\" type=\"hidden\" value=\"false\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"Active\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"width":"200px","command":[{"name":"Details","buttonType":"ImageAndText","text":"Details","click":error_handler},{"name":"edit","buttonType":"ImageAndText","text":"Edit"}]}],"pageable":{"buttonCount":10},"scrollable":false,"editable":{"confirmation":"Are you sure you want to delete this item?","mode":"inline","create":true,"update":true,"destroy":true},"dataSource":{"transport":{"prefix":"","read":{"url":"/Manage/Device/DeviceRules_GetForDevice?ViewSuffix=#=ViewSuffix#"},"update":{"url":"/Manage/Device/Device1_Update"},"create":{"url":"/Manage/Device/Device1_Create"},"destroy":{"url":"/Manage/Device/Device1_Delete"}},"pageSize":10,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-ajax","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"id":"DeviceRuleID","fields":{"ViewSuffix":{"type":"string"},"DeviceRuleID":{"type":"number"},"RuleName":{"type":"string"},"RulePriority":{"type":"number"},"Active":{"type":"boolean"},"Conditions":{"type":"object"},"deviceTag":{"type":"string"}}}}}});});
<\/script>
' Generated code:'var o,e=kendo.htmlEncode;with(data){o='\n    <div class="k-widget k-grid" id="Rules_'+(deviceTag)+'"><table cellspacing="0"><colgroup><col /><col /><col /><col /><col /><col style="width:200px" /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-field="DeviceRuleID" data-title="Device Rule ID" scope="col"><span class="k-link">Device Rule ID</span></th><th class="k-header" data-field="ViewSuffix" data-title="View Suffix" scope="col"><span class="k-link">View Suffix</span></th><th class="k-header" data-field="RuleName" data-title="Rule Name" scope="col"><span class="k-link">Rule Name</span></th><th class="k-header" data-field="RulePriority" data-title="Rule Priority" scope="col"><span class="k-link">Rule Priority</span></th><th class="k-header" data-field="Active" data-title="Active" scope="col"><span class="k-link">Active</span></th><th class="k-header" scope="col"><span class="k-link"> </span></th></tr></thead><tbody><tr class="t-no-data"><td colspan="6"></td></tr></tbody></table><div class="k-pager-wrap k-grid-pager"><a class="k-link k-state-disabled" 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-state-disabled" data-page="0" href="#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link 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-state-disabled" 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-info k-label">No items to display</span></div></div><script>\n\tjQuery(function(){jQuery("#Rules_'+(deviceTag)+'").kendoGrid({"columns":[{"title":"Device Rule ID","field":"DeviceRuleID","filterable":{},"encoded":true,"editor":"\u003cdiv class=\\\"t-widget t-numerictextbox\\\"\u003e\u003cinput class=\\\"t-input\\\" data-val=\\\"true\\\" data-val-number=\\\"The field DeviceRuleID must be a number.\\\" data-val-required=\\\"The DeviceRuleID field is required.\\\" id=\\\"DeviceRuleID\\\" name=\\\"DeviceRuleID\\\" style=\\\"width:50%\\\" type=\\\"text\\\" value=\\\"0\\\" /\u003e\u003ca class=\\\"t-link t-icon t-arrow-up\\\" href=\\\"';\" tabindex=\"-1\" title=\"Increase value\"\u003eIncrement\u003c/a\u003e\u003ca class=\"t-link t-icon t-arrow-down\" href=\";o+='\\\" tabindex=\\\"-1\\\" title=\\\"Decrease value\\\"\u003eDecrement\u003c/a\u003e\u003c/div\u003e\u003cscript type=\\\"text/javascript\\\"\u003e\tjQuery(\u0027';DeviceRuleID\u0027).tTextBox({val:0, step:1, minValue:-2147483648, maxValue:2147483647, digits:0, groupSize:3, negative:1, text:\u0027Enter value\u0027, type:\u0027numeric\u0027});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"DeviceRuleID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"View Suffix","field":"ViewSuffix","filterable":{},"encoded":true,"editor":"\u003cinput class=\"text-box single-line\" id=\"ViewSuffix\" name=\"ViewSuffix\" type=\"text\" value=\"\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"ViewSuffix\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Rule Name","field":"RuleName","filterable":{},"encoded":true,"editor":"\u003cinput class=\"text-box single-line\" id=\"RuleName\" name=\"RuleName\" type=\"text\" value=\"\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"RuleName\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Rule Priority","field":"RulePriority","filterable":{},"encoded":true,"editor":"\u003cdiv class=\"t-widget t-numerictextbox\"\u003e\u003cinput class=\"t-input\" data-val=\"true\" data-val-number=\"The field RulePriority must be a number.\" data-val-required=\"The RulePriority field is required.\" id=\"RulePriority\" name=\"RulePriority\" style=\"width:50%\" type=\"text\" value=\"0\" /\u003e\u003ca class=\"t-link t-icon t-arrow-up\" href=\";o+='\\\" tabindex=\\\"-1\\\" title=\\\"Increase value\\\"\u003eIncrement\u003c/a\u003e\u003ca class=\\\"t-link t-icon t-arrow-down\\\" href=\\\"';\" tabindex=\"-1\" title=\"Decrease value\"\u003eDecrement\u003c/a\u003e\u003c/div\u003e\u003cscript type=\"text/javascript\"\u003e\tjQuery(\u0027;o+='RulePriority\u0027).tTextBox({val:0, step:1, minValue:-2147483648, maxValue:2147483647, digits:0, groupSize:3, negative:1, text:\u0027Enter value\u0027, type:\u0027numeric\u0027});\u003c\\/script\u003e\u003cspan class=\\\"field-validation-valid\\\" data-valmsg-for=\\\"RulePriority\\\" data-valmsg-replace=\\\"true\\\"\u003e\u003c/span\u003e"},{"title":"Active","field":"Active","filterable":{},"encoded":true,"editor":"\u003cinput class=\\\"check-box\\\" data-val=\\\"true\\\" data-val-required=\\\"The Active field is required.\\\" id=\\\"Active\\\" name=\\\"Active\\\" type=\\\"checkbox\\\" value=\\\"true\\\" /\u003e\u003cinput name=\\\"Active\\\" type=\\\"hidden\\\" value=\\\"false\\\" /\u003e\u003cspan class=\\\"field-validation-valid\\\" data-valmsg-for=\\\"Active\\\" data-valmsg-replace=\\\"true\\\"\u003e\u003c/span\u003e"},{"width":"200px","command":[{"name":"Details","buttonType":"ImageAndText","text":"Details","click":error_handler},{"name":"edit","buttonType":"ImageAndText","text":"Edit"}]}],"pageable":{"buttonCount":10},"scrollable":false,"editable":{"confirmation":"Are you sure you want to delete this item?","mode":"inline","create":true,"update":true,"destroy":true},"dataSource":{"transport":{"prefix":"","read":{"url":"/Manage/Device/DeviceRules_GetForDevice?ViewSuffix='+(ViewSuffix)+'"},"update":{"url":"/Manage/Device/Device1_Update"},"create":{"url":"/Manage/Device/Device1_Create"},"destroy":{"url":"/Manage/Device/Device1_Delete"}},"pageSize":10,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-ajax","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"id":"DeviceRuleID","fields":{"ViewSuffix":{"type":"string"},"DeviceRuleID":{"type":"number"},"RuleName":{"type":"string"},"RulePriority":{"type":"number"},"Active":{"type":"boolean"},"Conditions":{"type":"object"},"deviceTag":{"type":"string"}}}}}});});\n<\/script>\n';}return o;'

Tony
Top achievements
Rank 1
 answered on 31 Jan 2013
3 answers
298 views
Hi, sorry if this has already been answered but I'm fairly new to this.  Anyway  I've implemented the Kendo Grid in my VB.NET MVC 3 project.  I thought it would be good to have a drilldown details template, but the details template won't populate with data...i've tried everything..can anyone help?  It's in VB.NET so there may be something lost in translation somewhere.

Any help would be greatly appreciated

@(Html.Kendo().Grid(Of Models.Device) _
    .Name("Devices") _
    .Groupable() _
    .Filterable() _
    .HtmlAttributes(New With {.style = "width: 100%", .align = "center"}) _
    .Columns(Function(columns)
                     columns.Bound(Function(p) p.Tag).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.Enabled).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.Description).Groupable(True).Width(200)
                     columns.Bound(Function(p) p.Suffix).Groupable(True).Width(200)
                     columns.Command(Function(command)
                                             command.Edit()
                                             command.Destroy()
                                     End Function).Width(200)
             End Function) _
    .Editable(Function(editable) editable.Mode(GridEditMode.InLine)) _
    .ToolBar(Function(toolbar) toolbar.Create()) _
    .DataSource(Function(dataSource)
                        dataSource.Ajax.Events(Function(events) events.Error("error_handler"))
                        dataSource.Ajax.Model(Sub(model) model.Id(Function(p) p.Suffix))
                        dataSource.Ajax.Create(Function(create) create.Action("Device_Create", "Device"))
                        dataSource.Ajax.Read(Function(read) read.Action("Device_Read", "Device"))
                        dataSource.Ajax.Update(Function(update) update.Action("Device_Update", "Device"))
                        dataSource.Ajax.Destroy(Function(delete) delete.Action("Device_Delete", "Device"))
                End Function) _
    .Events(Function(events)
                    events.DataBound("dataBound")
            End Function) _
        .ClientDetailTemplateId("RuleTemplate")
    )
 
  <script>
        function dataBound() {
            this.expandRow(this.tbody.find("tr.k-master-row").first());
        }
</script>
 
<script id="RuleTemplate" type="text/kendo-tmpl">
 
                                                                        @(Html.Kendo().Grid(Of Models.DeviceRule) _
                                                                        .Name("Rules_#=Suffix#") _
                                                                        .Columns(Function(columns)
                                                                                         columns.Bound(Function(p) p.Suffix).Groupable(True)
                                                                                         columns.Bound(Function(p) p.RuleID).Groupable(True)
                                                                                         columns.Bound(Function(p) p.Name).Groupable(True)
                                                                                         columns.Bound(Function(p) p.Priority).Groupable(True)
                                                                                         columns.Bound(Function(p) p.Active).Groupable(True)
                                                                                 End Function) _
                                                                        .DataSource(Function(dataSource)
                                                                                            dataSource.Ajax.Read(Function(read) read.Action("DeviceRules_Read", "Device", New With {.Suffix = "#=Suffix#"}))
                                                                                    End Function) _
                                                                        .Pageable() _
                                                                        .Sortable() _
                                                                        .ToClientTemplate())
                                                                 
</script>
Daniel
Telerik team
 answered on 31 Jan 2013
2 answers
296 views
I have kendo grid which has one string column that is using an autocomplete editortemplate. Now when the user first selects something from the list the text reads [object Object]. If the user does the selection again it shows up right. The editortemplate gets its values as an list of custom objects and uses one of the properties in that object. I've tried to override the ToString method of the object but alas it still returns the [object Object] on first selection. 

This same behaviour is present when using webcombo as editortemplate.

Anyone seen this behaviour before and how to fix it. I cannot reproduce it on any of the demos here so it has to do something with the setup my project is using.

The code of the column binding:
columns.Bound(o => o.Person).EditorTemplateName("Handlers");


And the template ("Handlers.cshtml"):
@(Html.Kendo().AutoComplete()
        .Filter(FilterType.StartsWith)
        .IgnoreCase(false)
        .Suggest(true) 
        .Name("Person")
        .DataTextField("Name")  
        .MinLength(1)
        .Template("#=Name#")
        .DataSource(source => { source.Read(read =>
              {
                  read.Data("GetQueryStringData").Action("GetHandlersTemplate", "AHJ").Type(HttpVerbs.Post);
              });
          })
)


Using mvc razor
Juuso
Top achievements
Rank 1
 answered on 31 Jan 2013
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Drag and Drop
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?