Telerik Forums
UI for ASP.NET MVC Forum
1 answer
41 views

Hi,

I am using the ASP.NET MVC Grid control on a page. The functionality is to fire a AJAX query when a Grid row is selected. The AJAX query calls the MVC Controller and gets a response HTML.

 The response HTML is a Tab Strip with 4 tabs , all of them are empty except for one which shows a hierarchy (built using <ul> and <li> tags).

Scenario,

  • When Grid loads, it gets the data from one of the MVC controllers
  • When a row is selected, the "onChange" event fires and a AJAX call pulls the HTML response with the Tabstrip
  • Once the AJAX response comes back, it is added to the DOM using $('#DrillDown').html(data)

Issue

Once the AJAX response is added to the DOM, the GriD is no longer accessible. None of the rows are selectable anymore, the below line returns null

var grid = $('#MasterGrid').data("kendoGrid");

 Any help appreciated.

-Harris

 

Boyan Dimitrov
Telerik team
 answered on 22 Jun 2015
1 answer
139 views

Hi there,

I am using the MultiSelectFor control bound to a model property in a MVC 5 razor webpage. I am able to select multiple items and create data in our backend system - however, I am running into a few problems when editing this data.

Model property:

[DataType("MultiSelect")]
[Required]
public List<string> Teams { get; set; }

 

Editor Template:

 

@model IList<string>
@Html.Kendo().MultiSelectFor(m => m)
     .DataTextField("Text")
     .DataValueField("Value")
     .Filter("contains")
     .AutoClose(false)
     .Placeholder("Please Select")
     .ValuePrimitive(true)
     .Deferred()
     .BindTo(selectList)
     .ToClientTemplate();

The list it is bound to is an IEnumerable<SelectListItem>

When the screen loads, everything appears fine - the multiselect field is bound to the correct items and displays correctly.

However, if I attempt to remove one of the selected items by clicking on the delete option, I receive a javascript error in kendo.all.min.js:

 
0x800a138f - JavaScript runtime error: Unable to get property 'top' of undefined or null reference

 

 

The multiselect then appears to have lost it's list of values, which will only reappear if I start typing.

Any ideas what could be the issue here? If I expand the list first prior to deleting, I receive no issues when removing a selected item.

 

Thanks,

Paul.

 

 

 

Georgi Krustev
Telerik team
 answered on 19 Jun 2015
1 answer
450 views

I am building an application in ASP.NET MVC where I am building different Kendo charts to show realtime data with SignalR. I am trying to let the Hub push data constantly to the chart. But I only manage to let the chart update its data on page load, not realtime.

 

<script src="@Url.Content("~/Scripts/jquery.signalR-2.2.0.min.js")"></script>
<script src="@Url.Content("~/signalr/hubs")"></script>
 
<script>
    var hub,
      hubStart;
 
    $(function () {
        var hubUrl = "http://localhost:52373/signalr/hubs";
        var connection = $.hubConnection(hubUrl, { useDefaultPath: false });
        hub = connection.createHubProxy("serverHub");
        $.connection.hub.logging = true;
        hubStart = connection.start();
    });
 
</script>

@(Html.Kendo().Chart<Model.ServerState>()
              .Name("server1")
              .Title(title => title
                  .Text("Server 1")
                  .Color("White")
                  .Font("25px Arial")
              )
              .Legend(legend => legend
                  .Color("Gray")
                  .Position(ChartLegendPosition.Bottom)
                  .Font("20px Arial")
              )
              .ChartArea(chartArea => chartArea
                  .Background("transparent")
              )
              .SeriesDefaults(seriesDefaults =>
                  seriesDefaults.Line().Style(ChartLineStyle.Smooth)
              )
              .Series(series =>
              {
                  series.Line(model => model.Performance.Memory).Name("Memory");
                  series.Line(model => model.Performance.Processor).Name("Processor");
              })
              .CategoryAxis(axis => axis
                  .Title(categoryTitle => categoryTitle
                    .Text("Time")
                    .Font("25px Arial"))
                  .Color("Gray")
                  .Labels(labels => labels
                      .Font("20px Arial"))
                  .MajorGridLines(lines => lines.Visible(false))
              )
              .ValueAxis(axis => axis
                  .Numeric().Labels(labels => labels.Format("{0}%"))
                  .Line(line => line.Visible(false))
                  .AxisCrossingValue(-10)
                  .Color("Gray")
                  .Labels(labels => labels
                      .Font("20px Arial"))
              )
              .Tooltip(tooltip => tooltip
                  .Visible(true)
                  .Format("{0}%")
                )
              .DataSource(source => source
                  .SignalR()
                  .AutoSync(true)
                  .Transport(transport => transport
                      .Promise("hubStart")
                      .Hub("hub")
                      .Client(c => c
                          .Read("read"))
                      .Server(server => server
                          .Read("read")
                          ))
                  .Schema(schema => schema
                      .Model(model =>
                      {
                          model.Id("Id");
                          model.Field("Id", typeof(int)).Editable(false);
                          model.Field("Memory", typeof(float));
                          model.Field("Processor", typeof(float));
                      }
                      )
            ))
)

 

//Best case:
public ServerStateEvent Read()
        {
        //Inside thread which pushes an message containing the object to kendo chart
                Clients.All.sendMessage(msg);
         }
//Current case, this method has to be called by kendo chart to update its data realtime
 public ServerStateEvent Read()
        {
         //this method gets data and returns it to kendo chart
                return msg;
         }

What I want is the "best case" where the Hub pushes data with the sendMessage function to kendo. This does not seems possible?

The current case works but only one time, the autoSync in kendo does not help.

T. Tsonev
Telerik team
 answered on 19 Jun 2015
7 answers
645 views
I have been pulling my hair out for the past two days on something that should be basic.    I have a grid using the ForeignKey to display a foreign key field.   When I open the screen all of the items with a existing foreign key assigned get interpreted correctly and show the Name column, not the key.   But, when I edit the column it shows the key with no combo.   Code snippets are in the attached file.

I am sure it is something simple, but I cannot figure it out.

Any help will be appreciated.





















Vladimir Iliev
Telerik team
 answered on 19 Jun 2015
1 answer
101 views

I am using a foreign key column in my grid, and populate the data from viewdata as below

 

              columns.ForeignKey(c => c.PersonId, (SelectList)ViewData["PersonSource"]);

 

I set the  ViewData["PersonSource"] at the page load and the values are updated correctly.

But in UI the column populates the values from the cache rather than the ViewData. It works fine if I manually clear the browser cache.

Anyways I can overcome this issue? 

Daniel
Telerik team
 answered on 18 Jun 2015
11 answers
628 views
I came across this thread on the same issue, but without the use of server wrappers, which in my mind sort of complicates what I'm trying to accomplish. It led me to this example at JS Bin, but I can't seem to implement this in my existing code. Do you guys have any suggestions in regards to approaching this particular 'problem'?

Here's what I have today:
<div class="span3">
    @(Html.Kendo().MultiSelect()
      .Name("tags")
      .Placeholder("No tags selected for this unit")
      .BindTo(new SelectList(Model.TagsAvailable))
      .Events(e => e
                .Select("select")
                .Change("change"))
      .Value(Model.TagsSelected.ToArray())
      )
</div>
 
<script>
    function select(e) {
        var dataItem = this.dataSource.view()[e.item.index()];
        var param = dataItem.Text;
        var url = '@Url.Content("~/UnitDetails/TagUnit/" + Model.UnitId)';
 
        $.ajax({
            url: url,
            data: { selectedItem: param },
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                
            },
            error: function () {
                
            }
        });
    };
 
    function change(e) {
        var dataItem = this;
        var param = dataItem.element.context.innerText;
        var url = '@Url.Content("~/UnitDetails/UnTagUnit/" + Model.UnitId)';
 
        $.ajax({
            url: url,
            data: { selectedItem: param },
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                
            },
            error: function () {

            }
        });
    };
</script>
This is before I start mixing the code from the example I referenced earlier. Chose to remove it, because it just clutters my code anyway, in addition to not working. Hope you guys can help!
Daniel
Telerik team
 answered on 18 Jun 2015
2 answers
48 views

when ever try to Implement the Server template it shows the Data and Every thing Good data is Coming and binding But when Click on the left most row to click it this comes to the Start of page if

 

i change   if (row.Index == 0)
        {
            row.DetailRow.Expanded = true;
        }

from 0 to 1 , 2 ,3 for every time it showing the data of the item for which it is set to expand but when ever try too click it doesn't so me detail and it comes up to the start of the page

Almas
Top achievements
Rank 1
 answered on 18 Jun 2015
1 answer
127 views

Hi,

I'm developing a leave management application and I have 2 types of leaves. Full day leave and half day leave. I want to limit the from and to date time pickers to same day if the full day event check box is not clicked in the default popup that appears in the add event popup.

 Currently it shows 1 day difference in from and to date pickers when full day event check box is not clicked and user can select any day with any gap in from and to date pickers. 

 I've tried to do it but failed. Would be grate if someone can help me on doing this.

 Thanks.

Vladimir Iliev
Telerik team
 answered on 18 Jun 2015
1 answer
374 views

Hi,

I've got a property in my model:

DateTime _ValidTo;
[DisplayName("Gültig bis")]
[DataType(DataType.Date, ErrorMessage="Falsches Datumsfornmat")]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true), ]
public DateTime ValidTo
{
     get { return _ValidTo; }
     set { _ValidTo = value; }
}

So in edit-mode the DatePicker is displayed.

But when I pick a a date, a message below the field appears The field "Gültig bis" must be a date.

This Message disappears when I enter the date in yyyy-MM-dd Format, but in ModelState this value is not accepted because of my property-attributes (this is a correct behaviour).

 

The question is, how can I get the Datepicker setup correctly correspondending my property-attributes?
I'm confused beacuse the Date ist picked correctly (in dd.MM.yyyy Format), but the picker itself does not accept it???

 

Greetings,

Denis

Daniel
Telerik team
 answered on 18 Jun 2015
1 answer
100 views

I'm new to Kendo UI MVC controls. I'm using a couple of grids inside a tabstrip. When I add a custom command to one of the grids, the grid does not render onto the page, but when I remove the custom command, it renders and displays the data as expected. Can anyone help? any help is greatly appreciated. My code is as follows.

 

<div id="jobstabdiv">
    @(Html.Kendo().TabStrip()
          .Name("Jobstabstrip")
          .Events(events => events
            .Select("selecttab"))
          .Items(tabstrip =>
          {
              tabstrip.Add().Text("Job Runs")
                  .Selected(true)
                  .Content(@<text>@RenderRunGrid()</text>);

              tabstrip.Add().Text("Incoming Files")
                  .Content(@<text>@RenderInFilesGrid()</text>);

          })
          .Events(tab => tab.Show("capturecurrenttab"))
    )
</div>

@helper RenderRunGrid()
{
    @(Html.Kendo().Grid<WI20Web.Models.RunsViewModel>()
        .Name("rungrid")
        .Columns(columns =>
        {
            columns.Command(command => command.Custom("status").Click("chgstatus"));
            columns.Bound(p => p.Id).Filterable(false).Width(50);
            columns.Bound(p => p.Mailshop_Job_Id).Width(200).Title("Mailshop Job Id");
            columns.Bound(p => p.Application_Id).Width(200).Title("App Id");
            columns.Bound(p => p.Application_Name).Title("App Name");
            columns.Bound(p => p.Status).Width(200);
            columns.Bound(p => p.Work_Order).Width(200).Title("Work Order");
            columns.Bound(p => p.Status).Hidden(true).ClientTemplate("<div class='run-status-#= Status#'></div>");
        })
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .Groupable()
        .HtmlAttributes(new { style = "height:650px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(10)
            .Read(read => read.Action("List_Data", "Runs"))
        )
        .Resizable(resize => resize.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
        .Events(events => events.DataBound("hilite_runs"))
    )
}

@helper RenderInFilesGrid()
{
    @(Html.Kendo().Grid<WI20Web.Models.IncomingFileViewModel>()
        .Name("infilesgrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.File_Path).Title("File Path");
            columns.Bound(p => p.File_Name).Title("File Name");
            columns.Bound(p => p.Date_Received).Title("Date Received").Format("{0:MM/dd/yyyy hh:mm:ss}");
            columns.Bound(p => p.File_Size).Title("File Size");
        })
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .Groupable()
        .HtmlAttributes(new { style = "height:650px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(10)
            .Read(read => read.Action("List_Data", "InFiles"))
        )
        .Resizable(resize => resize.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
    )
}

@section scripts
{
    function chgstatus(e) {
    alert("Change Status");
    }
}

Tony
Top achievements
Rank 1
 answered on 17 Jun 2015
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?