Telerik Forums
UI for ASP.NET MVC Forum
3 answers
2.2K+ views
hi,

I test kendoui MVC razor, follow this way my test project

_Layout.cshtml

   <script src="@Url.Content("~/Scripts/kendo/jquery.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/kendo.web.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/kendo.aspnetmvc.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/console.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/prettify.min.js")"></script>

index.cshtml 

@(Html.Kendo().DatePicker().Name("Birthday"))

But have error on javascript 

TypeError: jQuery(...).kendoDatePicker is not a function

Ilyas
Top achievements
Rank 1
 answered on 21 Jun 2013
1 answer
596 views
I have a Grid-component that is populated by a call to a service, from an action in my controller. I was wondering if it is possible to do this continuously, so that it will update the grid with real-time data? 

Right now, my view looks like this;
@model FleetMonitorModel
 
<div class="span12">
    <legend>Fleet Monitor</legend>
        <div>
        @(Html.Kendo().Grid<FleetMonitorModel>()
              .Name("Grid")
              .DataSource(ds => ds
                  .Ajax()
                  .Read(read => read.Action("Get", "FleetMonitor"))
              )
              .HtmlAttributes(new { style = "height:auto;" })
              .AutoBind(true)
              .Columns(columns =>
                  {
                      columns.Template(p => { }).ClientTemplate(" ").Width(310);
                      columns.Template(p => { }).ClientTemplate(" ").Width(250);
                      columns.Template(p => { }).ClientTemplate(" ").Width(150);
                      columns.Template(p => { }).ClientTemplate(" ");
                      columns.Template(p => { }).ClientTemplate(" ").Width(80);
                  })
              .ClientRowTemplate(Html.Partial("_ClientRowTemplate", Model).ToHtmlString())
              .Pageable()
              .Sortable())
    </div>
</div>
And my controller like this:
    private FleetMonitorModel Model { get; set; }
 
    ...      
 
    public ActionResult Get([DataSourceRequest] DataSourceRequest request)
    {
        UnitContract[] listOfUnitsFromService = Client.GetListOfUnits(true);
 
        Model = new FleetMonitorModel()
                    {
                        UnitDetails = GenerateUnitDetails(listOfUnitsFromService.ToList()),
                        Refresh = true
                    };
 
        return Json(Model.UnitDetails.ToDataSourceResult(request));
    }
}

Basically, the service will provide a steady stream of updated data, causing it to be more or less real-time.. All I want to accomplish, is to refresh the grid with my new data and update the graphical elements of my template. Current template is working fine, but data is only refreshed when page is refreshed.
Vladimir Iliev
Telerik team
 answered on 21 Jun 2013
6 answers
194 views
Hi,

I currently have a model with several properties, one of which is a Spatial object (of type DbGeometry). If this spatial property is NULL, everything works fine, but if it's not, my ListView throws an exception (ironically enough, it thinks the problem is that the list is null). My list creation code is below:

@(Html.Kendo().ListView(Model.ToList())
    .Name("s-list-event-container")
    .TagName("div")
    .HtmlAttributes(new { @class = "s-list-container" })
    .ClientTemplateId("template-list-event")
)
where "Model" refers to an IEnumerable object.

If there is no way to populate the ListView while the model has a DbGeometry object, is there at least a way to ignore specific properties of a model?

Thanks,
Jeff
Petur Subev
Telerik team
 answered on 21 Jun 2013
3 answers
767 views
Is it possible to filter an MVC Listview based on text entered into a textbox? if so how would one go about doing so?

for example a listview that returns over 400 records, and needs to be searchable.

Stephen Graham
Top achievements
Rank 1
 answered on 20 Jun 2013
1 answer
68 views
This screen shot says it all:
https://dl.dropboxusercontent.com/u/17474320/Validator-Miss-positioned.png

The code has:

            @(Html.Kendo().DropDownList()
                  .Name("OwnerUserId")
                  .HtmlAttributes(new { style = "width:200px", @required = true })
                  .OptionLabel("(Select User)")
                  .DataTextField("Name")
                  .DataValueField("Id")
                  .DataSource(source => {
                       source.Read(read => {
                           read.Action("GetCascadeUser", "ComboBox")
                              .Data("filterUsers");
                       }).ServerFiltering(true);
                  })
                  .Enable(true)
                  .AutoBind(true)
            )

How do I fix that, so the validation is positioned correctly?
Petur Subev
Telerik team
 answered on 20 Jun 2013
5 answers
110 views
Hi there,

I'm sure this is a simple problem to solve, but it completely eludes me - I have an MVC grid bound to my model, and a custom command column to show a popup window with additional details about that row. However, on execution, the actual command instead shows the following:

<a class="k-button k-button-icontext k-grid-View Details" href="/Reporting/Stock?Stock-page=2&Stock-pageSize=10"><span></span>View Details</a>
Note the href - this is wrong, but I cannot for the life of me understand where it's appearing from!

My grid setup:
<% Html.Kendo().Grid(Model)
           .Name("Stock")
           .Columns(columns =>
               {
                   columns.Bound(o => o.SKU).Title("SKU");
                   columns.Template(o => Html.Truncate(o.Name, 60)).Title("Name");
                   columns.Template(o => Html.ActionLink(Html.Truncate(o.Region, 40), "Details", "Stock"));
                   columns.Bound(o => o.Type);
                   columns.Bound(o => o.Quantity);
                   columns.Command(command => command.Custom("View Details").Click("showDetails"));
               })
           .Pageable()
           .Groupable()
           .Sortable()
           .Render();
           %>
Anyone have insight into this, what am I missing?
Big Daftie
Top achievements
Rank 1
 answered on 20 Jun 2013
1 answer
125 views
Hi there,

I've just installed KendoUI, but the grid examples aren't working.  It is showing this error:

Server Error in '/' Application.
The system cannot find the file specified

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:
Line 1: @model IEnumerable<Kendo.Mvc.Examples.Models.Product>
Line 2:
Line 3: @(Html.Kendo().Grid(Model)
Line 4: .Name("Grid")
Line 5: .Columns(columns => {

Source File: c:\Program Files (x86)\Telerik\Kendo UI for ASP.NET MVC Q1 2013\wrappers\aspnetmvc\Examples\Areas\razor\Views\web\grid\serverbinding.cshtml    Line: 3

This happens to all the grid examples.  Other examples I checked are working, e.g. Menu, Multiselect.  How can I get the grids to work?

Amanda
Vladimir Iliev
Telerik team
 answered on 20 Jun 2013
1 answer
188 views
Using the ASP.NET MVC wrappers, I have a tabstrip that loads it's respective tabitems contents from Html actions

@(Html.Kendo().TabStrip()
       .Name("inst_details_tabstrip")
       .Items(tabstrip => {
            tabstrip.Add().Text("Details").Content(@<text>@Html.Action("InstitutionDetails", "InstitutionSetup")</text>);
                       
            tabstrip.Add().Text("Locations").Content(@<text>@Html.Action("ServiceLocations", "InstitutionSetup")</text>);
                       
            tabstrip.Add().Text("Devices").Content(@<text>@Html.Action("Printers", "InstitutionSetup")</text>);
                       
            tabstrip.Add().Text("Users").Content(@<text>@Html.Action("UserList", "InstitutionSetup")</text>);
                       
        }))
This process works fine.  However, there is one case where when the page loads, the Users tab should be loaded by default rather than the Details tab.    

The following snippet will change the rendered state of the tabstrip to show the Users tab as selected, but will not switch to its corresponding contents (instead continues to show the Details tab content)


var tabstrip = $("#inst_details_tabstrip").data("kendoTabStrip");
tabstrip.select(tabstrip.tabGroup.find(':contains("Users")'));
var item = tabstrip.items()[3];
tabStrip.reload(item);
is there something simple I am missing?
Petur Subev
Telerik team
 answered on 20 Jun 2013
1 answer
226 views
Hi ,

I will appreciate if someone could help me with this issue.
I have a Model with the following structure:

public class PieChartModel
    {
        public string YearMonth { get; set; } //this have a data like 2013.05
        public decimal Balance { get; set; }
        public string ClientName { get; set; }
        public decimal EndingPercentage { get; set; }
    }

My task is to display this information in a graph that
contain multiple axis represented like in Image 1

The code I used to get the graph on Image 1 was this one:

@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
    .Name(Model.ChartName)
    .HtmlAttributes(new {style = "height: 500px"})
    .Title(Model.ChartTitle)
    .Legend(legend => legend
        .Position(ChartLegendPosition.Bottom)
    )
        .DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))
                                      )        
    .Series(series => {
        series.Column(model =>
model.Balance)
            .GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
        series.Line(model =>
model.EndingPercentage).Name("Percent")
            .Axis("percent").Labels(false);
    })
    .CategoryAxis(axis => axis
        .Categories(model => model.ClientName)
        .Labels(label => label.Visible(true).Rotation(45))
        .AxisCrossingValue(0, 21)
    )
    .ValueAxis(axis => axis.Numeric()
        .Labels(labels => labels
            .Format("${0}")
        ).Title("Indicator
$"))
    .ValueAxis(axis => axis
        .Numeric("percent")
            .Title("Frequency")
            .Labels(labels => labels.Format("{0}%"))
            .Min(0).Max(100)
    )
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0:N0}")
    )
)

but our client wants each bar to have a different color and
be shown as a legend in the graph as you can see on Image 2

Grouping by client I can implement  this request, but then the line graph is not represented properly.
The code I used to group is almost the same

@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
    .Name(Model.ChartName)
    .HtmlAttributes(new {style = "height: 500px"})
    .Title(Model.ChartTitle)
    .Legend(legend => legend
        .Position(ChartLegendPosition.Bottom)
    )
        .DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))       
.Group(group => group.Add(model => model.ClientName)))        
    .Series(series => {
        series.Column(model => model.Balance)
            .GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
        series.Line(model =>
model.EndingPercentage).Name("Percent")
            .Axis("percent").Labels(false);
    })
    .CategoryAxis(axis => axis
        .Categories(model => model.ClientName)
        .Labels(label => label.Visible(true).Rotation(45))
        .AxisCrossingValue(0, 21)
    )
    .ValueAxis(axis => axis.Numeric()
        .Labels(labels => labels
            .Format("${0}")
        ).Title("Indicator
$")
    )
    .ValueAxis(axis => axis
        .Numeric("percent")
            .Title("Frequency")
            .Labels(labels => labels.Format("{0}%"))
            .Min(0).Max(100)
    )
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0:N0}")
    )
)

What do I need to do in order to show the data in the graph displaying the bars with different color and showing  a legend per client,   and at the same time be able to see properly the line chart?

Please let me know if you need more information.

Thanks, Ainel



Iliana Dyankova
Telerik team
 answered on 20 Jun 2013
3 answers
552 views
Dear Kendo Team,

I have a grid of with a row that contains several values for each item.  I would also like to be able to filter and group by that row but I haven't got that far yet because I can't even display the information.

The grid looks like so:

@( Html.Kendo().Grid<ProjectXMVC3.ViewModel.PersonnelIndexViewModel>()
        .Name("Personnel")
        .Columns(columns =>
        {
            columns.Bound(o => o.AssetId).Hidden();
            columns.Bound(o => o.Num).Hidden();
            columns.Bound(o => o.Name).Width(150);
            columns.Bound(o => o.Email).Width(200);
            columns.Bound(o => o.AssetSubTypeName).ClientTemplate("# var j = AssetSubType.length; for(var i = 0; i < j; i++){# #: AssetSubType[i] #  #}#");
            columns.Bound(o => o.DateBirth).Format("{0:d}").Width(100);
            columns.ForeignKey(o => o.NationalityId, (System.Collections.IEnumerable)ViewBag.NationalityId, "CountryId", "Country").Title("Nationality");
            columns.ForeignKey(o => o.PreferedAirport, (System.Collections.IEnumerable)ViewBag.PreferedAirport, "AirportId", "AirportName").Title("Prefered Airport");
            columns.ForeignKey(o => o.ContractorTypeId, (System.Collections.IEnumerable)ViewBag.ContractorTypeId, "ContractorTypeId", "ContractorDescrip").Title("Contractor Type");
            columns.Command(com =>
            {
                com.Custom("Details").Click("onPersonSelected");
                com.Edit();
                com.Custom("Block").Click("onBlocked");
                com.Destroy();
            }).Width(240);
        })
        .DataSource(d => d
            .Ajax()
            .Model(model => model.Id(p => p.AssetId))
            .Read(read => read.Action("Read_Personnel", "Personnel"))
            .Events(events => events.Error("error_handler"))
            .Update(update => update.Action("Personnel_Update", "Personnel"))
            .Destroy(destroy => destroy.Action("Personnel_Destroy", "Personnel"))
        )
        .Events(ev => { ev.DataBound("onDataBound"); ev.Edit("onEdit"); })
        .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Person"))
 )

The problems occurs at the client template line which causes the grid to crash.  I can output the length, individual subtypes but as soon as it loops it crashes in a very terminal way. 

I've tried:

"# for(var i = 0; i <  AssetSubType.length;  i++){#  #: AssetSubType[i] #  #}#"
"# for(var i = 0; i <  AssetSubType.length;  i++){#  #= AssetSubType[i] #  #}#"

This works:

"# if(AssetSubType.length > 0){#  #: AssetSubType[0] #  #}#"

Any assistance would be very much appreciated.  Thanks in advance.
Daniel
Telerik team
 answered on 20 Jun 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?