Hi,
What is the best way to group by a field in a ListView?
I'd like to have something along the lines of this
Species: Human
1: Toby
2: Rob
Species: Dog
3: Harry
4: Rover
Species: Cat
5: Tickles
The model schema is as below
ID Name Species
1 Toby Human
2 Rob Human
3 Harry Dog
4 Rover Dog
5 Tickles Cat
<script type="text/x-kendo-tmpl" id="template"> <div class="person"> <div class="id">#:ID#</div> <div class="name">#:Name#</div> </div></script><div id="persons"> @(Html.Kendo().ListView<Person>() .Name("persons") .TagName("div") .ClientTemplateId("template") .DataSource(ds => ds .Model(m => m.Id(p => p.ID)) .Read(r => r.Action("PersonsRead", "Home")) .Group(g => g.Add(p => p.Species)) ))I managed to get as far as the above, but this throws an error as it is passing the Species field and value to the client template from the Group method.
Any ideas?
I have to install kendo mvc in vs 2012 (just moved from 2010 to 2012) however I cannot see where I can get the msi installer for the latest version.
Please advise.
p.s the notes indicate that one should copy the css and js and that should do it - however - this does not help when you want to have the Telerik menu item in Visual studio installed or the matter of the Kendo MVC dlls being installed et al.
As well - I do need the Telerik menu options installed in Visual Studio to allow for future updates as well.
Please advise.
I have a form with a drop down list inside of it. When the form is posted I want the data in the drop down list to be written into Class B, which is an attribute of Class A on the MVC side.
Can this be done? Is there any way to format or pull the data from the Drop down list directly into Class B, which is inside of Class A? Is there some way to map the input from the drop down list to this element?
Seeing an odd issue trying to setup some inline editing using the Grid controller. The Grid displays correctly and functions correctly until I try to perform an edit. When I click the edit button, make edits and then press update, the line comes back with empty values.
Upon inspection, the model being passed to the controller ActionResult is null (expect for ID and date). Code below. Took a look at some of the null threads and not seeing a common denominator. Any thoughts:
Grid Control:
@(Html.Kendo().Grid(Model) .Name("commissionGrid") .Columns(columns => { columns.Bound(p => p.CommissionId); columns.Bound(p => p.TenantId); columns.Bound(p => p.SimpleName); columns.Bound(p => p.StartDate); columns.Bound(p => p.CustomerName); columns.Bound(p => p.CustomerNumber); columns.Command(command => { command.Edit(); }).Title("Commands"); }) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Navigatable() .Sortable() .DataSource(dataSource => dataSource .Ajax() .Batch(true) .PageSize(10) //.ServerOperation(false) .Model(model => model.Id(p => p.CommissionId)) .Update(update => update.Action("EditingInline_Update", "Commissions")) ) )Controller:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, CommissionViewModel commissionViewModel) { if (commissionViewModel != null && ModelState.IsValid) { using (var test = new CommissionContext()) { try { var entity = new Commission(); entity.CommissionId = commissionViewModel.CommissionId; entity.CustomerName = commissionViewModel.CustomerName; entity.CustomerNumber = commissionViewModel.CustomerNumber; entity.SimpleName = commissionViewModel.SimpleName; entity.StartDate = commissionViewModel.StartDate; entity.TenantId = commissionViewModel.TenantId; test.Commissions.Attach(entity); test.Entry(entity).State = EntityState.Modified; test.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException v) { Console.WriteLine("Exception is {0}", v); } } } return Json(new[]{commissionViewModel}.ToDataSourceResult(request, ModelState)); }
Simple use case; a pretty common one I would assume:
I have more than one kendo button displayed within an MVC view. When one of the buttons fires the "submit" event, I want to be able to grab a handle on which button fired the submit from within my controller. I had assumed that you could assign "button" to the name attribute and then determine through the button's "value" property which button fired the event.
The controller signature would look like this:
[HttpPost]
public ActionResult(string button) { determine course of action based on button's value property...}
I'm actually taken back at the fact that one of the most fundamental uses of the input button type is simply not given any means to do this simply. Of course, I could be blind and missing something, but I've searched forums and Telerik documentation and found little if anything on performing this basic task.
Thanks!
Hi
i have add an grid and set some styles to it like row color from databound event and command button styles and it works fine, but when i cancel popup edit i found that row loss the style of if and when i try to fire edit event throw js i got err:
Uncaught TypeError: Cannot read property 'find' of undefinedmy js code is:
@section scripts{ <script type="text/javascript"> function getAdditionalData() { return { Clinic_Code_ID: $('#Clinic_Code_ID').val(), Doctor_ID: $('#Doctor_ID').val(), Visit_Date: $('#Visit_Date').val(), }; } $(document).ready(function () { $('#showGrid').click(function () { if ((!$('#Clinic_Code_ID').val()) && (!$('#Doctor_ID').val()) && (!$('#Visit_Date').val())) { $("#SHPTData").data("kendoGrid").dataSource.data([]); alert("من فضلك ادخل القيمة المراد البحث عنها"); return; } else { $('#SHPTData').data('kendoGrid').dataSource.fetch(); } }); }); function dataBound() { var grid = this; grid.tbody.find("tr[role='row']").each(function () { var model = grid.dataItem(this); if (model.Clinic_Code_ID == 1) { $(this).css("color", "blue"); } else { $(this).css("color", "green"); } $(".btn-success").removeClass("k-button"); $(".btn-danger").removeClass("k-button"); }); } function onEdit(e) { //Triggered when the window is closed (always) e.container.data("kendoWindow").bind("deactivate", function () { dataBound(); }) } 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>}i try on function onEdit replace dataBound() with:
$(".my_Editbtn").removeClass("k-button");$(".my_Delbtn").removeClass("k-button");Full Grid Code:
@(Html.Kendo().Grid<MhafezClinic.Models.DBContext.VisitData>() .Name("SHPTData") .HtmlAttributes(new { style = "font-weight:bold; vertical-align:middle; font-size:medium;" }) .AutoBind(false) .Columns(columns =>{ columns.Bound(e => e.ClinicCode) .ClientTemplate("#=ClinicCode.Clinic_Code_Name#") .Sortable(false).HtmlAttributes(new { @style = "text-align:center;" }) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Filterable(false).Title("العيادة").Width(65); columns.Bound(e => e.PT_Clinic_ID) .HtmlAttributes(new { @style = "text-align:center;" }) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Title("رقم الملف الطبى").Width(130); columns.Bound(e => e.PT_Name) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Title("إسم المريض").Width(200); columns.Bound(e => e.Nots) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }).Filterable(false) .Sortable(false).Title("ملاحظات").Width(180); columns.Bound(e => e.PT_Phone_No) .HtmlAttributes(new { @style = "text-align:center;" }) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Filterable(false).Sortable(false).Title("رقم التليفون").Width(130); //columns.Bound(e => e.Visit_Date) // .HtmlAttributes(new { @style = "text-align:center;" }) // .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }).Width(105) // .Filterable(false).Sortable(false); columns.Bound(e => e.VisitTime) .HtmlAttributes(new { @style = "text-align:center;" }) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Filterable(false).Sortable(false).Title("وقت الكشف").Width(100); columns.Bound(e => e.Kashf) .ClientTemplate("#=Kashf.Kashf_Name#") .HtmlAttributes(new { @style = "text-align:center;" }) .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }) .Filterable(false).Sortable(false).Title("نوع الكشف").Width(150); columns.Command(command => { command.Edit().HtmlAttributes(new { @class = "my_Editbtn", @style = "margin-left:10px; font-weight:bold;" }).Text("تعديل"); command.Destroy().HtmlAttributes(new { @class = "my_Delbtn", @style = "font-weight:bold;" }).Text("حذف"); }).HtmlAttributes(new { @style = "text-align:center;" });}) .Pageable() .Sortable() .Editable(editable => editable.Mode(GridEditMode.PopUp)) .DataSource(source => source.Ajax() .Model(model => { model.Id(e => e.ID); model.Field(e => e.ID).Editable(false); }) .Events(events => events.Error("error_handler")) .Read(read => read.Action("GetData", "VisitDatas").Data("getAdditionalData")) .Update(update => update.Action("GetData", "VisitDatas").Data("getAdditionalData")) .Destroy(destroy => destroy.Action("GetData", "VisitDatas").Data("getAdditionalData")) ) .Events(e => e.DataBound("dataBound").Edit("onEdit")) )and command buttons style is back, but i need rows style "color" back again
so how can i do that please?

I have a couple of TreeViews on a razor page, one of which has at least 10 levels.
I need to be able to expand, collapse, and search each of the trees.
I found the following on the forums that supposedly expands the TreeView and it does work - kind of:
http://www.telerik.com/forums/is-there-a-way-to-expand-all-nodes-in-multiple-level-for-treeview#Of6kvLQLNE-YgOdLSPjUlA
It says, "Create a button for it and add event onclick like below (b is counter of not expand node):"
$("#expandAllNodes").click(function (e) { e.preventDefault(); expandNextLevel(); }); function expandNextLevel() { setTimeout(function () { var treeview = $("#treeview").data("kendoTreeView"); var b = $('.k-item .k-plus').length; treeview.expand(".k-item"); treeview.trigger('dataBound'); if (b > 0) { expandNextLevel(); } }, 200); }TIA,
Bob Mathis