Telerik Forums
UI for ASP.NET MVC Forum
1 answer
144 views
I am using trial version of Kendo UI chart 2013.2.716. Is it possible to create 3D charts using Kendo UI chart?

Thanks,
Renju
Iliana Dyankova
Telerik team
 answered on 10 Sep 2013
3 answers
5.0K+ views
If I'm loading the content on my window using LoadContentFrom - which loads the content of another view, how do I close the window if I have a button in that other view with an ID "close"

    $(document).ready(function () {
        var window = $("#window").data("kendoWindow");
 
        $("#open").click(function (e) {
            window.center();
            window.open();
        });
 
        $("#close").click(function (e) {
            window.close();
        });
 
    });

The above java script is within my main view, which doesn't seem to work, presumably because the close button isn't on the same view?

How do I get the window to close by a click of a button in a different view which is rendered in my modal window?
Gerry
Top achievements
Rank 1
 answered on 09 Sep 2013
3 answers
471 views
I am trying to create a simple customer search/edit form using Kendo.ListView() in MVC4.

I am running into a problem when trying to remove a value from the form, MVC is reporting that the field is required, when it is not.  Further investigation has revealed that the whole Validation framework is not working.

Here is my model:
public class ClientModel
{
    private readonly Guid _id;
 
    public string Id
    {
        get { return _id.ToString(); }
    }
 
    [Required(ErrorMessage = "Please enter a Name for this client.")]
    [Display(Name = "Name")]
    public string Name { get; set; }
 
    [Display(Name = "Address")]
    public string AddressLine1 { get; set; }
 
    public string AddressLine2 { get; set; }
 
    public string AddressLine3 { get; set; }
 
    [Display(Name = "Email Address")]
    public string EmailAddress { get; set; }
 
    [Display(Name = "Home Phone")]
    public string HomePhone { get; set; }
 
    [Display(Name = "Cellular Phone")]
    public string CellularPhone { get; set; }
 
    [Display(Name = "Work Phone")]
    public string WorkPhone { get; set; }
}
And my main view:
@using Models
 
@section Styles {
    <link href="@Url.Content("~/Content/Client.css")" rel="stylesheet" type="text/css" />
}
 
<div class="k-toolbar k-grid-toolbar">
    <a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add Client</a>
</div>
 
<script type="text/x-kendo-tmpl" id="client-view-template">
    <div class="client">
        <h3>${Name}</h3>
        <div class="client-details">
            <dl>           
                <dt>${AddressLine1}</dt>
                <dt>${AddressLine2}</dt>
                <dt>${AddressLine3}</dt>
            </dl>
            <h4>Phone</h4>
            <dl>
                <dt>(H) ${HomePhone}</dt>
                <dt>(M) ${CellularPhone}</dt>
                <dt>(W) ${WorkPhone}</dt>
            </dl>
            <dl>
                <dt>${EmailAddress}</dt>
            </dl>
            <div class="edit-buttons">
                <a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span>Edit</a>
                <a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span>Delete</a>
            </div>
        </div>
    </div>
</script>
 
@(Html
      .Kendo()
      .ListView<ClientModel>()
      .Name("ClientList")
      .TagName("div")
      .ClientTemplateId("client-view-template")
      .DataSource(dataSource => dataSource
                                    .Model(model =>
                                               {
                                                   model.Id("Id");
                                                   model.Field<string>("Id").DefaultValue(Guid.Empty).Editable(false);
                                                   model.Field<string>("Name").DefaultValue(string.Empty);
                                                   model.Field<string>("Address1").DefaultValue(string.Empty);
                                                   model.Field<string>("Address2").DefaultValue(string.Empty);
                                                   model.Field<string>("Address3").DefaultValue(string.Empty);
                                                   model.Field<string>("HomePhone").DefaultValue(string.Empty);
                                                   model.Field<string>("CellularPhone").DefaultValue(string.Empty);
                                                   model.Field<string>("WorkPhone").DefaultValue(string.Empty);
                                                   model.Field<string>("EmailAddress").DefaultValue(string.Empty);
                                               })
                                    .Read(read => read.Action("ClientRead", "Clients"))
                                    .Create(create => create.Action("ClientCreate", "Clients"))
                                    .Update(update => update.Action("ClientUpdate", "Clients"))
                                    .Destroy(destroy => destroy.Action("ClientDestroy", "Clients"))
      )
      .Editable(editable => editable.TemplateName("ClientModelEdit"))
      )
 
<script>
    $(function() {
        var listView = $("#ClientList").data("kendoListView");
 
        $(".k-add-button").click(function(e) {
            listView.add();
            e.preventDefault();
        });
    });
 
</script>
And finally the edit template:
@using Models
@model ClientModel
 
@{ Html.EnablePartialViewValidation(); }
 
<div class="client-edit">
     
    @Html.ValidationSummary(true);
 
    @Html.HiddenFor(model => model.Id)
    <dl>
        <dt>@Html.LabelFor(p => p.Name)</dt>
        <dd>
            @Html.EditorFor(p => p.Name)
        </dd>
        <dt>
            @Html.LabelFor(p => p.AddressLine1)
        </dt>
        <dd>
            @Html.EditorFor(p => p.AddressLine1)
        </dd>
        <dt>
        </dt>
        <dd>
            @Html.EditorFor(p => p.AddressLine2)
        </dd>
        <dt>
        </dt>
        <dd>
            @Html.EditorFor(p => p.AddressLine3)
        </dd>
        <dt>
            @Html.LabelFor(p => p.HomePhone)
        </dt>
        <dd>
            @Html.EditorFor(p => p.HomePhone)
        </dd>
        <dt>
            @Html.LabelFor(p => p.CellularPhone)
        </dt>
        <dd>
            @Html.EditorFor(p => p.CellularPhone)
        </dd>
        <dt>
            @Html.LabelFor(p => p.WorkPhone)
        </dt>
        <dd>
            @Html.EditorFor(p => p.WorkPhone)
        </dd>
        <dt>
            @Html.LabelFor(p => p.EmailAddress)
        </dt>
        <dd>
            @Html.TextBoxFor(p => p.EmailAddress)
        </dd>
    </dl>
    <div class="edit-buttons">
        <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span>Save</a>
        <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span>Cancel</a>
    </div>
 
</div>
I'm just wondering if I am missing something.  I have been trying to figure this out for 3 days now.

Thanks
Randy
Top achievements
Rank 1
 answered on 09 Sep 2013
1 answer
54 views

I have a server bound grid that is working well until I add a second command button to a row. When I do this the formatting is thrown off and a second grid is placed at the bottom of the first. Does anyone recognize the problem?

@(Html.Kendo().Grid<TimeAndAttendance.Models.DaysActivityViewModel>(Model.DayActivities)
       .Name("DaysActivities")
       .Columns(columns =>
       {
           columns.Bound(da => da.Facility);
           columns.Bound(da => da.Position);
           columns.Bound(da => da.Shift);
           columns.Bound(da => da.Paycode);
           columns.Bound(da => da.Hours);
           columns.Bound(da => da.Notes);
           columns.Command(command => { command.Edit().Text("");  });
       })
       .Scrollable()
       .HtmlAttributes(new { style = "height:200px;" })
       .DataSource(dataSource => dataSource
           .Server()
           .Update(update => update.Action("Edit", "IndividualTimeEntry"))
           .Destroy(destroy => destroy.Action("Delete", "IndividualTimeEntry"))
           .Model(model => model.Id(da => da.ID))
           )
  )
Iliana Dyankova
Telerik team
 answered on 09 Sep 2013
2 answers
122 views
Hello,

I have the need to sort a column of strings using a subset of the string parsed into an integer.    For example:

AA1
AA2
AA3
AB4
CC5

I need the sorting to strip out all alpha's and sort by the integer.   Please advise how I can do this using the following implementation:
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Id).Width(60);
        columns.Bound(p => p.Title).Width(250); 
    })
    .Sortable()
    .DataSource(dataSource => dataSource
               .Ajax()
               .PageSize(10)
               .Read(read => read.Action("Get", "Grid", new {view = "MyActive", showAll = false}))
               )
      )
Daniel
Telerik team
 answered on 09 Sep 2013
1 answer
106 views
Hello everybody

I have a grid with a detailtemplate. This detailtemplate contains also a grid.
My parent grid refers to an Edition-Model which contains many Articles. When the user expands an Edition-Row, the detailgrid contains all correct Articles.

The problem now is, that i want to check, if one Article is allready read by the user. So i want to insert a conclusion, that i can show one or another value in a column of the detailgrid.

On this website, i found the template-syntax: http://docs.kendoui.com/getting-started/framework/templates/overview#template-syntax

But it doesnt work fine. In the detailgrid the conclusion checks every time the parent-data (Edition) and not the detaildata (Article).

My ClientTemplate (for the detail grid)
columns.Bound(c => c.IsRead).ClientTemplate("" +
                "#if(IsRead== true) {#" +
                "Read"+
                "#} else{#" +
                "Not Read +
                "#}#")
                .Title("State").Width(120);

When i put an output in the ClientTemplate as shown in the link above, then the Template renders the correct data (with the \\# syntax)

Example (clienttemplate for the detail grid):
columns.Bound(c => c.IsRead).ClientTemplate("" +
                "#if(IsRead== true) {#" +
                "#=data.Id#"+      // Shows parent Id
                "#} else{#" +
                "\\#=data.Id\\# +     // Shows the correct id from the detail row
                "#}#")
                .Title("State").Width(120);
My question now: How can I check the data of the detailrow in a conclusion??

Edit:
For better understanding: I have the sam CSharp - Model in both Grids. When i make two diffrent models, then it is the same situation. Only one diffrence: Javascript-Console says: Undifined Property (for IsRead). Because my actual Edition - Model has no property named IsRerad.

Thanks and have a nice day
MJ
Daniel
Telerik team
 answered on 09 Sep 2013
2 answers
432 views
I am currently trying out kendo.ui for asp.net mvc

I have a model

public class RegionViewModel 
{
  public int Id { get; set; }
  public string Name { get; set; }
   public IList<VillageViewModel> Villages {get; set; }
}

public class VillageViewModel
{
 public int Id {get; set; }
   public string Name {get; set; }
}

Basically its a many to many relationship .. the model is built using entity framework.
But that is not really the problem.

I am trying to select multiple Villages from a huge list and assign them to a region. The region is the main row entity for a grid.
I am using the MultiSelect widget in an editor template.

This works fine, selection works and everything. But on clicking update no ajax request is sent to the server ( i am using inline edit mode ) 
I have tried everything, looked at the sample provided here: http://www.kendoui.com/code-library/mvc/grid/using-multiselect-in-grid.aspx

But i cannot get this to work apparently.
One requirement that i have btw is that the multiselect has to be using ajax as well since for exampel there are 17.000 possible villages in our database right now
and loading them all on creating the editor takes to long, and also makes the editor basically unusable.

Here is my field and column setup code:

 fields.Field(Accessor).DefaultValue(new List<VillageViewModel>());
columns.Bound(t => t.Villages).EditorTemplateName("MultiReference");

My editor template: ( not using the html helper ,since that does not allow for using serverpaging right now )

select id="Villages">
</select>

<script>

    jQuery(function() {
        jQuery("#Villages").kendoMultiSelect(
            {
                "dataSource":
                {
                    "transport":
                    {
                        "prefix": "",
                        "read":
                        {
                            "url": "/admin/regions/villages",
                            "data": function() {
                                return kendo.ui.MultiSelect.requestData("#Villages");
                            }
                        }
                    },
                    "serverFiltering": true,
                    "serverPaging": true,
                    "pageSize": 20,
                    "filter": [],
                    "schema": {
                        "errors": "Errors"
                    }
                },
                "dataTextField": "Name",
                "dataValueField": "Id",
                "value": []
            });
    });
</script>

And here is the final grid script that gets rendered:

jQuery(function () {
    jQuery("#regionsGrid").kendoGrid({
        "columns": [{
            "title": "Name",
            "field": "Name",
            "filterable": {},
            "encoded": true,
            "editor": "\u003cinput class=\"k-textbox\" id=\"Name\" name=\"Name\" type=\"text\" value=\"\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"Name\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"
        }, {
            "title": "Villages",
            "template": "#for(var i = 0; i\u003c data.length; i  ){#\u003cspan\u003e#:data[i].Name#\u003c/span\u003e#}#",
            "field": "Villages",
            "filterable": {},
            "encoded": true,
            "editor": "\r\n\r\n\u003cselect id=\"Villages\"\u003e\r\n\u003c/select\u003e\r\n\r\n\u003cscript\u003e\r\n\r\n    jQuery(function() {\r\n        jQuery(\"#Villages\").kendoMultiSelect(\r\n            {\r\n                \"dataSource\":\r\n                {\r\n                    \"transport\":\r\n                    {\r\n                        \"prefix\": \"\",\r\n                        \"read\":\r\n                        {\r\n                            \"url\": \"/Admin/regions/Villages\",\r\n                            \"data\": function() {\r\n                                return kendo.ui.MultiSelect.requestData(\"#Villages\");\r\n                            }\r\n                        }\r\n                    },\r\n                    \"serverFiltering\": true,\r\n                    \"serverPaging\": true,\r\n                    \"pageSize\": 20,\r\n                    \"filter\": [],\r\n                    \"schema\": {\r\n                        \"errors\": \"Errors\"\r\n                    }\r\n                },\r\n                \"dataTextField\": \"Name\",\r\n                \"dataValueField\": \"Id\",\r\n                \"value\": []\r\n            });\r\n    });\r\n\u003c/script\u003e\r\n\r\n\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"Villages\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"
        }, {
            "title": "Commands",
            "width": "200px",
            "command": [{
                "name": "edit",
                "buttonType": "ImageAndText",
                "text": "Edit"
            }, {
                "name": "destroy",
                "buttonType": "ImageAndText",
                "text": "Delete"
            }]
        }],
        "pageable": {
            "buttonCount": 10
        },
        "sortable": true,
        "scrollable": false,
        "editable": {
            "confirmation": "Are you sure you want to delete this record?",
            "mode": "inline",
            "create": true,
            "update": true,
            "destroy": true
        },
        "toolbar": {
            "command": [{
                "name": null,
                "buttonType": "ImageAndText",
                "text": "Add new record"
            }]
        },
        "dataSource": {
            "transport": {
                "prefix": "",
                "read": {
                    "url": "/Admin/regions/List"
                },
                "update": {
                    "url": "/Admin/regions/Update",
                    "data": gridSerialize
                },
                "create": {
                    "url": "/Admin/regions/Create",
                    "data": gridSerialize
                },
                "destroy": {
                    "url": "/Admin/regions/Destroy"
                }
            },
            "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": "Id",
                    "fields": {
                        "Villages": {
                            "type": "object",
                            "defaultValue": []
                        },
                        "Id": {
                            "editable": false,
                            "type": "number"
                        },
                        "Name": {
                            "type": "string"
                        },
                        "Slug": {
                            "type": "string"
                        }
                    }
                }
            },
            "autoSync": true
        }
    });
});

Or are there any other recommended options to edit many to many relationships in a grid ? 









Bernhard
Top achievements
Rank 1
 answered on 06 Sep 2013
1 answer
703 views
I'm trying to learn both Kendo and MVC at the same time, so bear with me.  In the code below, I know I could populate my grid via Ajax and frankly I'd be more comfortable with that, but I'm trying to acquaint myself with the basics, so I'd like to avoid it for now.

I would like the contents of my Grid to be restricted by both a DropDownList and a Search box.  The issue is that when you turn on Pageable for a Kendo Grid, it wants to GET the next page.  But since my DropDownList and my Search box will not be part of the GET params, they won't be available to the Action.  So the question:

Is it hopelessly naive to use Grid without Ajax or is there a straightforward way to either include my additional parameters or make the pagination use the form POST?

@using (Html.BeginForm(null, null, FormMethod.Post, new { id="searchForm" })) {
   <script>
      function submit() { $("#searchForm").submit() }
   </script>
   @(Html.Kendo().DropDownListFor(m => m.ListID).DataValueField("ID").DataTextField("Name")
         .BindTo(Model.Lists).Events(e => e.Change("submit")))
   @Html.Kendo().AutoCompleteFor(m => m.SearchText).Placeholder("Search")
   <input type="submit" value="Search" />
   @Html.Kendo().Grid(Model.Albums).Name("AlbumsGrid").BindTo(Model.Albums).Pageable().Sortable()
}
Petur Subev
Telerik team
 answered on 06 Sep 2013
1 answer
168 views
We do not want to highlight the group header on collapse expand. Basically it should not have k-state-focused and k-state-highlight applied to it when I expand or collapse. 

Can you please advise a trick?
Iliana Dyankova
Telerik team
 answered on 06 Sep 2013
0 answers
114 views
On our current project we have implemented server-side grouping, however, I can find no documentation on how to manually populate the aggregated totals of the groupings into the DataSourceResult object that the Kendo Grid expects from the server.  Newing up a List<AggregateResult> doesn't seem to work as many of the properties of the AggregateResult object are read only.  We can't use the ToDataSourceResult() extension method because we're also paging on the server, so we're only pulling back subsets of the total dataset at whatever page size the user has selected.

Is there some documentation somewhere that I'm just not seeing?  If so, can you point it out to me, and if not, what guidance can you offer in populating those aggregated totals?
David
Top achievements
Rank 1
 asked on 06 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?