Telerik Forums
Kendo UI for jQuery Forum
5 answers
435 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
1 answer
558 views
Hi,

I have a page (relevant code below) which carries out the following :

1. User enters a value into an auto-complete text box
2, Upon selecting an auto complete option, an ajax call is made in order to fill 2 dropdownlists
3. User is required to select a value from each dropdownlist
4. Once a value has been selected on both, they click on the add button and my bound table is updated
5. User can remove rows added to the table

The rows added in step 4 are contained in an array in the observable object.
The first time the page loads points 1 to 5 work as expected.....

However, if the user enters a new search into the auto-complete box and fires the select event, the second time the ajax call is made, the relationship between my viewmodel and UI objects are broken. 

The code which is executing is identical so please could someone shed some light on why the second time around this breaks.

<input type="text" id="txtBox" style="width:300px;" />

<div id="fixturesBindable" style="padding:0 !Important;">
<table>
<thead>
<tr>
                        <th>Col1</th>
                        <th>Col2</th>
</tr>
</thead>
        
<tbody data-template="row-template" data-bind="source: Fixtures"></tbody>
</table>

<select id="a_teamsdropdown" data-role="dropdownlist" data-text-field="TeamFullName" data-value-field="Id" data-bind="source: Teams" style="width:200px;"></select>
<select id="a_oppteamsdropdown" data-role="dropdownlist" data-text-field="TeamFullName" data-value-field="Id" data-bind="source: 
OpponentTeams" style="width:200px;"></select>

<button type="button" data-bind="click: addFixture">Add Fixture</button>

<script id="row-template" type="text/x-kendo-template">
<tr>
<td><input type="hidden" id="team"  data-bind="attr: { name: TeamModelName, value: TeamId }" /></td>
<td><input type="hidden" id="oppteam" data-bind="attr: { name: OppModelName, value: OppTeamId }" /></td>
</tr>
</script>

</div>


<script>
$(document).ready(function () {
        var viewModel = kendo.observable({
            Teams: <%= Model.Teams %>,
            OpponentTeams: [],
            Fixtures: [],
            addFixture: function (e) {
                var Fixtures = this.get("Fixtures");
                var teamId = $("#a_teamsdropdown").val();
                var teamName = $("#a_teamsdropdown>option:selected").text();
                var oppteamId = $("#a_oppteamsdropdown").val();
                var oppteamName = $("#a_oppteamsdropdown>option:selected").text();

                    this.get("Fixtures").push({
                        TeamFullName: teamName,
                        TeamId: teamId,
                        OppTeamFullName: oppteamName,
                        OppTeamId: oppteamId,
                        OrderIndex: this.get("Fixtures").length,
                        TeamModelName: 'Fixtures[' + this.get("Fixtures").length + '].TeamId',
                        OppModelName: 'Fixtures[' + this.get("Fixtures").length + '].OpponentTeamId'
                    });
            },
            resetFixture: function(){
                var Fixtures = this.get("Fixtures");
                $.each(Fixtures, function (key, fixture) {
                    Fixtures.splice(0, 1);
                });
            }
        });

opponents = $("#txtBox").kendoAutoComplete({
            minLength: 3,
            dataTextField: "Name",
            filter: "contains",
            dataSource: new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "/url/Ajax",
                        type: "POST",
                        data: function () { return { searchText: $("#txtBox").val()} 
                        },
                        complete: function (data) {
                            opponents.list.width(400);
                        }
                    }
                },
                pageSize: 10,
                serverPaging: true,
                serverSorting: true,
                schema: {
                    total: "count",
                    data: "data",
                    model: {
                        id: "Id",
                        fields: {
                            Id: { editable: false }
                        }
                    }
                }
            }),
            change: function () {
                this.dataSource.read();
            },
            select: function (e) {
                $.each(opponents.dataSource.data(), function (index, value) {
                    if (e.item.text() == value.Name) {
                        selectedOpponent = value;
                        $('#Fixture_OpponentTeam_Id').val(selectedOpponent.Id);
                        $('#OpponentName').val(selectedOpponent.Name);
                        $.ajax({
                            url: 'GetOpponentTeams',
                            data: { schoolId: selectedOpponent.Id, seasonId: seasonId, sportId: sportsId },
                            type: 'GET',
                            success: function (data) {
                                viewModel.OpponentTeams = data;
                                kendo.bind($("#fixturesBindable"), viewModel);
                            },
                            error: function (xhr, ajaxOptions, thrownError) {
                                //alert('Error during process: \n' + xhr.responseText);
                                alert(thrownError);
                            }
                        });
                        return;
                    }
                });
            }

        }).data("kendoAutoComplete");
</script>
Felipe Casanova
Top achievements
Rank 1
 answered on 31 Jan 2013
3 answers
120 views
I have a unique situation where I have three DataSources that are sync'd at the same time when a user clicks the save button. I have the Kendo UI Progress control displayed when user clicks the button, but I only want it to hide when the longest of the three ajax calls completes. I am familiar with jQuery's $.ajaxCompelete() function, but it runs for every ajax call. How can I determine which call is the last? Do take note that not all three DataSource syncs occur, because if there are no changes in it, then it's ajax call is not initiated.
Petur Subev
Telerik team
 answered on 31 Jan 2013
3 answers
269 views
I'm setting up an MVC grid with a true/false column to represent if the row is a selected row (to store in the database). The problem occurs when i click the true/false cell, a checkbox shows up as expected, but when i attempt to click the checkbox, instead of checking the box, the cell goes back to display mode. If I click the cell to put it in editing mode and use the space bar, it will check the checkbox just fine, but I need the ability to use a mouse click to check the box.

Here's the grid:
Html.Kendo().Grid<SelectedProjects>()
                .Name("StaticViewGrid")
                .HtmlAttributes(new { @style = "display:inline-block;" })
                .Columns(columns =>
                {
                    columns.Bound(o => o.Selected);
                    columns.Bound(o => o.SystemID);
                    columns.Bound(o => o.ProjectName);
                    columns.Bound(o => o.Environment);
                    columns.Bound(o => o.SitEntryDate).Format("{0:d}");
                    columns.Bound(o => o.SitExitDate).Format("{0:d}");
                    columns.Bound(o => o.ProductionInstallDate).Format("{0:d}");
                })
                .ToolBar(toolbar => toolbar.Save())
                .Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
                .Filterable()
                .Sortable()
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Batch(true)
                    .ServerOperation(false)
                    .Model(model =>
                    {
                        model.Id(o => o.EngagementID);
                        model.Field(o => o.Selected).Editable(true);
                        model.Field(o => o.SystemID).Editable(false);
                        model.Field(o => o.ProjectName).Editable(false);
                        model.Field(o => o.Environment).Editable(false);
                        model.Field(o => o.SitEntryDate).Editable(false);
                        model.Field(o => o.SitExitDate).Editable(false);
                        model.Field(o => o.ProductionInstallDate).Editable(false);
                    })
                    .Read(read => read.Action("SelectedEngagementItemData""Amethyst"))
                    .Update(update => update.Action("SelectedEngagementItems_Update""Amethyst"))
                )




Here's the model.

    public partial class SelectedProjects
    {
        public Guid EngagementViewID { getset; }
        public string EngagementViewName { getset; }
        public bool Selected { getset; }
        public int EngagementID { getset; }
        public Nullable<int> SystemID { getset; }
        public string ProjectName { getset; }
        public string Environment { getset; }
        public Nullable<DateTime> SitEntryDate { getset; }
        public Nullable<DateTime> SitExitDate { getset; }
        public Nullable<DateTime> ProductionInstallDate { getset; }
    }



I've looked through the forums for similar issue, but I cannot see what I'm doing wrong. Please help if you can.



Dimiter Madjarov
Telerik team
 answered on 31 Jan 2013
1 answer
121 views
Hello,

I have the following grid: 

@(Html.Kendo().Grid<JobCodeModel>()
        .Name("JobCodeGrid")
        .ToolBar(toolbar => toolbar.Create())
        .Scrollable(scrolling => scrolling.Enabled(false))
        .Filterable(filtering => filtering.Enabled(true))
        .Pageable(paging => paging.Enabled(true).PageSizes(true))
        .Sortable(sorting => sorting.Enabled(true))
        .Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
        .DataSource(datasource => datasource
            .Ajax()
            .Read(read => read.Action("JobCode_Read", "Admin"))
            .Create(create => create.Action("JobCode_Create", "Admin"))
            .Update(update => update.Action("JobCode_Update", "Admin"))
            .Model(model => model.Id(p => p.JobCodeID))
            )
 
 
 
        .Columns(columns =>
            {
                columns.Bound(c => c.JobCode);
                columns.Bound(c => c.JobCodeDescription);
                columns.Bound(c => c.Active);
 
                columns.Command(commands =>
                    {
                        commands.Edit();
 
                    }).Width(43).Visible(true);
            })
             
       )

[HttpPost]
       public ActionResult JobCode_Read([DataSourceRequest]DataSourceRequest request)
       {
           DataSourceResult result = null;
           using (MyEntities entities = new MyEntities())
           {
               result = (from r in entities.JobCodes
                         select new JobCodeModel
                         {
                             JobCodeID = r.JobCodeID,
                             JobCode = r.JobCode1,
                             JobCodeDescription = r.JobCodeDescription,
                             Active = r.Active
 
                         }).ToDataSourceResult(request);
           }
           return Json(result);
 
       }

And when i deploy the site to IIS6 i get a 404 on JobCode_Read (yes, i have the proper wildcard set up) and the data does not load (obviously).

It also happens if i change this post to a get and return Json(result, JsonRequestBehavior.AllowGet);

When i deploy it to IIS7 it goes through no problem.

Am I missing a setting in II6, or will this just not work in IIS6?

Has anyone else encountered this?
comgiu
Top achievements
Rank 2
 answered on 31 Jan 2013
1 answer
140 views
I currently have an example that fires my delete, update, and read methods on my WCF rest service. For whatever reason, I cannot get the create to work. Am I doing something wrong?

<script>
        $(document).ready(function () {
            var crudServiceBaseUrl = "http://localhost/IqaRestService/Service1",
            dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: crudServiceBaseUrl + "/getquestions",
                        dataType: "json"
                    },
                    update: {
                        url: crudServiceBaseUrl + "/update",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json"
                    },
                    create: {
                        url: crudServiceBaseUrl + "/create",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json"
                    },
                    destroy: {
                        url: crudServiceBaseUrl + "/delete",
                        dataType: "json",
                        type: "DELETE",
                        contentType: "application/json"
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options) {
                            return kendo.stringify({ question: options });
                        }
                    }
                },
                schema: {
                    model: {
                        id: "QuestionId",
                        fields: {
                            QuestionId: { type: "string" },
                            QuestionText: { type: "string" },                           
                            Comment: { type: "string" },
                            Answer: { type: "string" }
                        }
                    }
                }
            });
 
            $(".k-add-button").click(function (e) {
                listView.add();
                e.preventDefault();
            });
 
            var listView = $("#listView").kendoListView({
                dataSource: dataSource,
                editable: true,
                selectable: "single",
                template: kendo.template($("#template").html()),               
                editTemplate: kendo.template($("#editTemplate").html())
            }).data("kendoListView");
 
        });
    </script>
[OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/getquestions")]
        public List<IqaQuestion> GetQuestions()
        {
            return this.Store;           
        }
 
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/update", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        public bool SaveQuestion(IqaQuestion question)
        {           
            return true;
        }
 
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/create", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        public bool CreateQuestion(IqaQuestion question)
        {           
            return true;
        }
 
        [OperationContract]
        [WebInvoke(Method = "DELETE", UriTemplate = "/delete", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        public bool RemoveQuestion(IqaQuestion question)
        {
            return false;
        }
Alexander Valchev
Telerik team
 answered on 31 Jan 2013
3 answers
483 views
Telerik Team,

Is there a way to validate an autocomplete in the popup editor grid?  In the grid definition of my field, I have added an editor parameter to render out the kendo autocomplete which will retrieve remote data.

columns: [
                  { field: "EmployeeName", title: "Employee Name", editor: employeeAutoCompleteEditor }
]

The autocomplete and everything works.  But the validation defined in the datasource of the autocomplete doesn't work.

schema: {
                        model: {
                            fields: {
                                Employee: {
                                    type: "string",
                                    validation: { required: true}
                                }
                            }
                        }

If I took out the editor: employeeAutoCompleteEditor from the grid column definition, the validation works on that datasource.  Is it possible to have the autocomplete with validation by defining it in the schema?

Thanks,
Danny
Alexander Valchev
Telerik team
 answered on 31 Jan 2013
5 answers
752 views
Hi,

I am having issue with Paging on kendo grid when binding to remote data source through WCF service.

It doesn't work when I load the page, the paging only works only when I click on any column for sorting.

For Sorting, the column sorts but the image for sort direction doesn't appear on the column.

For Filtering, the filtering is enabled, but filtering isn't appearing for the columns.

I have attached the solution with this post. Please help.
Alexander Valchev
Telerik team
 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
Drag and Drop
Application
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?