Telerik Forums
UI for ASP.NET MVC Forum
1 answer
89 views
Hi Team,

we are facing issues in Gantt chart. if we select first row and than second row first row is not disabled[ it is in editable mode]

kindly help us. please find the attachment for your reference.

Thanks

Manoj
Bozhidar
Telerik team
 answered on 14 Nov 2014
1 answer
156 views
Is there anyway to implement optimistic concurrency with the Kendo Grid?
Petur Subev
Telerik team
 answered on 13 Nov 2014
3 answers
215 views
Hi,


I have a kendo mvc grid on Razor View, which is collecting data by AJAX request to Controller.

I Would like to save page visited by user and when that user comes back grid automatically would load last visited page.

View code:

@(Html.Kendo().Grid<OrderListItemModel>()
    .Name("orders")
    .Columns(columns =>
    {
....
 .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(order => order.Id))
        .PageSize(10)
        .Read(read => read.Action(Mvc.Crud.AjaxFilter,...

any my AjaxFilterMethod:

public virtual ActionResult AjaxFilter([DataSourceRequest]DataSourceRequest request, FilterModel filter)
        {
            var model = GetListItems(filter);
            var result = model.ToDataSourceResult(request);
            return Json(result);
        }

any suggestions how i can achieve this?

Best Regards
Vladimir Iliev
Telerik team
 answered on 13 Nov 2014
1 answer
1.1K+ views
Guys,

I have two comboboxes on a Custom Editor for Scheduler that are called "CustomerID" and "SiteID" - when selecting a customer, if that customer has a single site, I wish for the single item in the "SiteID" box to be selected.

I have the UI functionality working as expected, but yet ModelState.IsValid is always false and the "SiteID" value is always an empty guid  e.g. the Selected Value for the SiteID dropdownlist does not seem to be passed back to the model.

The definition of CustomerID and SiteID are below:

  <div class="k-edit-field">
           @(Html.Kendo().DropDownListFor(model => model.CustomerID)
              .Name("CustomerID")
              .HtmlAttributes(new { style = "width:300px", data_bind = "value :CustomerID" })
              .OptionLabel("Select...")
              .DataTextField("CustomerName")
              .DataValueField("CustomerID")
              .Events(events=>events.DataBound("customersLoaded"))
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetCascadeCustomers", "Job");
                  }).ServerFiltering(true);                  
              })              
              
            )
        </div>
        <div class="k-edit-label">
            @(Html.LabelFor(model => model.SiteID))
        </div>
        <div class="k-edit-field">
           @(Html.Kendo().DropDownListFor(model => model.SiteID)
              .HtmlAttributes(new { style = "width:300px", data_bind="value: SiteID" })
              .OptionLabel("Select...")
              .DataTextField("SiteName")
              .DataValueField("SiteID")
              .Events(events => events.DataBound("sitesLoaded"))
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetCascadeSites", "Job")
                          .Data("filterSites");
                  })
                  .ServerFiltering(true);
              })
              .Enable(true)
              .AutoBind(false)
              .CascadeFrom("CustomerID")                           
        )       

The events relating to each are defined in javascript as below:

function filterSites() {
        return {
            CustomerID: $("#CustomerID").val()
        };
    }

function customersLoaded(e) {
        // handle the event
        var dropdownlist = $("#CustomerID").data("kendoDropDownList");
        // selects item if its value is equal to "test" using predicate function
        if (_custID != null) {
            dropdownlist.value(_custID);
            //dropdownlist.value(dropdownlist.value());

        }
    }

    function sitesLoaded(e) {
        // handle the event
        var dropdownlist = $("#SiteID").data("kendoDropDownList");
        // selects item if its value is equal to "test" using predicate function
        if (_siteID != null) {
            dropdownlist.value(_siteID);

        }
        else
        {
            //select first items if 1
            if( dropdownlist.dataSource.data().length == 1)
            {
                dropdownlist.select(1);
               
                
            }
        }


    }


I use the dropdownlist.select method to select the first item in the SiteID DropDownList.

A video of the problem can be found here:

http://screencast.com/t/xdmTpREq

If you could let me know what I need to change that would be great.
Georgi Krustev
Telerik team
 answered on 13 Nov 2014
1 answer
284 views
Based on the selection of dropdownlist item, I would need to query the database with the selected item and display the results as chart.
Could anyone please point me to the example url
T. Tsonev
Telerik team
 answered on 13 Nov 2014
2 answers
306 views
Hi there,

I want to add a ajax backed ComboBox item into the form template for selecting a company.
(I do not want to use the ressources functionality for that)

The form is working correctly, but the CompanyId ist not transferred in the server request for saving the event.
Am I blind? What am I missing here?

My Scheduler:
@(Html.Kendo().Scheduler<ScheduleViewModel>()
      .Name("Schedules")
      .AutoBind(false)
      .DateHeaderTemplate("<strong>#=kendo.toString(date, 'ddd., d. MMM.')#</strong>")
      .AllDayEventTemplateId("event-template")
      .EventTemplateId("event-template")
      .Mobile(MobileMode.Auto)
      .Date(DateTime.Today)
      .Editable(e => e.TemplateId("editor-template"))
      .Views(views => {
          views.DayView(i => i.ShowWorkHours(true));
          views.WorkWeekView(i => i.Selected(true).ShowWorkHours(true));
          views.WeekView(i => i.ShowWorkHours(true));
          views.MonthView();
          views.AgendaView();
      })
      .Events(events => events.DataBound("onDataBound"))
      .Timezone("Europe/Vienna")
      .ShowWorkHours(true)
      .Resources(res => {
          res.Add(i => i.ScheduleType)
              .Name("ScheduleType")
              .Title("Termintyp")
              .BindTo(new[] {
                  new {Name = "Intern", Id = 1, Color = "#43ac6a"},
                  new {Name = "Extern", Id = 2, Color = "#5bc0de"},
                  new {Name = "Abwesend", Id = 3, Color = "#ccc"}
              })
              .DataValueField("Id")
              .DataTextField("Name")
              .DataColorField("Color");
 
          res.Add(i => i.UserIDs)
              .Name("Users")
              .Title("Teilnehmer")
              .DataSource(dataSource => dataSource
                  .Read(read => read.Action("_Schedule", "Account")))
              .DataValueField("Id")
              .DataTextField("Name")
              .DataColorField("Color")
              .Multiple(true);
 
      }
      )
      .DataSource(dataSource => dataSource
          .Model(model => {
              model.Id(i => i.Id);
              model.Field(i => i.ScheduleType).DefaultValue(0);
              model.Field(i => i.CompanyId).Editable(true);
          })
          .Read(read => read.Action("_Index", "Schedule").Data("updateGrid"))
          .Create(create => create.Action("_Create", "Schedule"))
          .Update(update => update.Action("_Edit", "Schedule"))
          .Destroy(destroy => destroy.Action("_Delete", "Schedule"))
      ))


My template:

<script id="editor-template" type="text/x-kendo-template">
    <div class="k-edit-label">
        <label for="title">Titel</label>
    </div>
    <div class="k-edit-field" data-container-for="title">
        <input name="title" class="k-input k-textbox" type="text" data-bind="value:title">
    </div>
     
    <div class="k-edit-label">
        <label for="companyid">Firma</label>
    </div>
    <div class="k-edit-field" data-container-for="companyid">
        @(Html.Kendo().ComboBox()
                  .Name("CompanyId")
                  .HtmlAttributes(new { data_bind = "value:CompanyId"})
                  .DataSource(source => source.Read("Autocomplete", "Company").ServerFiltering(true))
                  .DataTextField("name")
                  .DataValueField("id")
                  .Filter(FilterType.StartsWith)
                  .Placeholder("Firma wählen...")
                  .ToClientTemplate()
        )
    </div>
 
    <div class="k-edit-label">
        <label for="start">Beginn</label>
    </div>
    <div class="k-edit-field" data-container-for="start">
        <input name="start" type="text" required data-type="date" data-role="datetimepicker" data-bind="value: start,invisible: isAllDay" />
        <input name="start" type="text" required data-type="date" data-role="datepicker" data-bind="value: start,visible: isAllDay" />
    </div>
 
    <div class="k-edit-label">
        <label for="end">Ende</label>
    </div>
    <div class="k-edit-field" data-container-for="end">
        <input name="end" type="text" required data-type="date" data-role="datetimepicker" data-bind="value: end ,invisible:isAllDay" />
        <input name="end" type="text" required data-type="date" data-role="datepicker" data-bind="value: end ,visible:isAllDay" />
    </div>
 
    <div class="k-edit-label">
        <label for="isAllDay">Ganztägig</label>
    </div>
    <div class="k-edit-field" data-container-for="isAllDay">
        <input type="checkbox" name="isAllDay" data-type="boolean" data-bind="checked:isAllDay">
    </div>
 
    <div class="k-edit-label">
        <label for="description">Bechreibung</label>
    </div>
    <div class="k-edit-field" data-container-for="description">
        <textarea name="description" class="k-textbox" data-bind="value:description"></textarea>
    </div>
     
 
 
    <div class="k-edit-label">
        <label for="recurrenceRule">Wiederholen</label>
    </div>
    <div data-container-for="recurrenceRule" class="k-edit-field">
        <div data-bind="value:recurrenceRule" id="recurrenceRule" name="recurrenceRule" data-role="recurrenceeditor"></div>
    </div>
 
 
    <div id="resourcesContainer">
    </div>
 
 
 
    <script>
        jQuery(function() {
            var container = jQuery("\#resourcesContainer");
            var resources = jQuery("\#Schedules").data("kendoScheduler").resources;
            dbg = resources;
            for( var resource = 0; resource<resources.length; resource++) {
                jQuery(kendo.format('<div class="k-edit-label"><label for="{0}">{1}</label></div>', resources[resource].name, resources[resource].title))
                      .appendTo(container)
 
                var labcont = jQuery(kendo.format('<div class="k-edit-field"></div>'))
                      .appendTo(container)
 
                if(resources[resource].multiple)                 {
                    jQuery(kendo.format('<select data-bind="value: {0}" name="{0}">', resources[resource].field))
                      .appendTo(labcont)
                      .kendoMultiSelect({
                          dataTextField: resources[resource].dataTextField,
                          dataValueField: resources[resource].dataValueField,
                          dataSource: resources[resource].dataSource,
                          valuePrimitive: resources[resource].valuePrimitive,
                          itemTemplate: kendo.format('<span class="glyphicon glyphicon-user" style="color:\#= data.{0}?{0}:"none" \#"></span>\#={1}\#', resources[resource].dataColorField, resources[resource].dataTextField),
                          tagTemplate: kendo.format('<span class="glyphicon glyphicon-user" style="color:\#= data.{0}?{0}:"none" \#"></span>\#={1}\#', resources[resource].dataColorField, resources[resource].dataTextField)
                      });
 
                } else {
                    jQuery(kendo.format('<select data-bind="value: {0}" name="{0}">', resources[resource].field))
                     .appendTo(labcont)
                     .kendoDropDownList({
                         dataTextField: resources[resource].dataTextField,
                         dataValueField: resources[resource].dataValueField,
                         dataSource: resources[resource].dataSource,
                         valuePrimitive: resources[resource].valuePrimitive,
                         optionLabel: "Unbestimmt",
                         template: kendo.format('<span class="k-scheduler-mark" style="background-color:\#= data.{0}?{0}:"none" \#"></span>\#={1}\#', resources[resource].dataColorField, resources[resource].dataTextField)
                     });
                }
            }
 
        });
        messageTranslate();
        <\/script>
 
    </script>

many thanks,
Chris
Georgi Krustev
Telerik team
 answered on 12 Nov 2014
1 answer
89 views
I'm using MVC5.

I haven't been able to find an example of modifying parent / child or header / detail type of situation.

Currently I have a ViewModel that contains single data from a db record which is the parent or header info.  

The ViewModel also contains an IEnumerable of the child record type.

In the view I have elements of the header or parent data and a Grid for the child data.  How do I send the parent key when doing, say, a "create" of new data in the grid after save is pressed.

The grid is setup to use Ajax and updates are done in Batch.  

The issue is that I see how I can bind the columns to the child records, but how do I get the parent id sent when "save" is pressed?

Thanks in advance.



Petur Subev
Telerik team
 answered on 11 Nov 2014
11 answers
371 views
ok so I have created a chart, that takes data from a MVC action method and populates a chart, in your example here http://dojo.telerik.com/@tsvetomir/UvON You have autosync set to true, but where is the push coming from? How do I send the updated information? My chart loads Initially but does not change when any of the status' change.

Code for chart: 
<script>
    var connection = $.hubConnection();
    var hub = connection.createHubProxy("centralHub");
    connection.logging = true;
    var hubPromise = connection.start();

</script>
@{

    double[] clockins = new double[5];
    double[] breaks = new double[5];
    double[] lunch = new double[5];
    if (Model != null)
    {
        foreach (var item in Model)
        {
            switch (item.SiteName)
            {
                case "Mabel":
                    switch (item.TypeName)
                    {
                        case "ClockIn":
                            clockins[0] = item.Count;
                            break;
                        case "Break":
                            breaks[0] = item.Count;
                            break;
                        case "Lunch":
                            lunch[0] = item.Count;
                            break;
                    }
                    break;
                case "Harp":
                    switch (item.TypeName)
                    {
                        case "ClockIn":
                            clockins[1] = item.Count;
                            break;
                        case "Break":
                            breaks[1] = item.Count;
                            break;
                        case "Lunch":
                            lunch[1] = item.Count;
                            break;
                    }
                    break;
                case "Pendleton":
                    switch (item.TypeName)
                    {
                        case "ClockIn":
                            clockins[2] = item.Count;
                            break;
                        case "Break":
                            breaks[2] = item.Count;
                            break;
                        case "Lunch":
                            lunch[2] = item.Count;
                            break;
                    }
                    break;
                case "Granite":
                    switch (item.TypeName)
                    {
                        case "ClockIn":
                            clockins[3] = item.Count;
                            break;
                        case "Break":
                            breaks[3] = item.Count;
                            break;
                        case "Lunch":
                            lunch[3] = item.Count;
                            break;
                    }
                    break;
                case "HQ":
                    switch (item.TypeName)
                    {
                        case "ClockIn":
                            clockins[4] = item.Count;
                            break;
                        case "Break":
                            breaks[4] = item.Count;
                            break;
                        case "Lunch":
                            lunch[4] = item.Count;
                            break;
                    }
                    break;
            }
        }
    }
}
<body>
    <div class="k-chart">
        @(Html.Kendo().Chart<TcStatusChartData>()
              .Name("chart")
              .Title("Agents by status")
              .Legend(legend => legend
                  .Position(ChartLegendPosition.Bottom)
              )
              .SeriesDefaults(seriesDefaults =>
                  seriesDefaults.Bar().Stack(ChartStackType.Normal)
              )
              .Series(series =>
              {
                  series.Column(new double[] { clockins[0], clockins[1], clockins[2], clockins[3], clockins[4] }).Stack(ChartStackType.Normal).Name("Clocked In");
                  series.Column(new double[] { breaks[0], breaks[1], breaks[2], breaks[3], breaks[4] }).Stack(ChartStackType.Normal).Name("On Break");
                  series.Column(new double[] { lunch[0], lunch[1], lunch[2], lunch[3], lunch[4] }).Stack(ChartStackType.Normal).Name("On Lunch");
              }).SeriesColors("#33FF33", "#CCFF33", "#FF9933")
              .CategoryAxis(axis => axis
                  .Categories("Mabel", "Harp", "Pendleton", "Granite", "HQ")
                  .MajorGridLines(lines => lines.Visible(false))

              )
              .ValueAxis(axis => axis
                  .Numeric()
                  .Labels(labels => labels.Format("{0}"))
                  .Max(100)
                  .Line(line => line.Visible(false))
                  .MajorGridLines(lines => lines.Visible(true))
              ).DataSource(datasource => datasource
                  .SignalR().AutoSync(true)

                  .Transport(tr => tr.Promise("hubPromise")
                      .Hub("hub")
                      .Server(server => server
                          .Read("chart_Read")
                          .Update("update")
                          .Destroy("desstroy")
                          .Create("create")))
              )
              .Tooltip(tooltip => tooltip
                  .Visible(true)
                  .Template("#= series.name #: #= value #")
              )
        )
    </div>
</body>

Kelso
Top achievements
Rank 1
 answered on 11 Nov 2014
1 answer
1.3K+ views
Hello,

I am attempting to display a link when you open the editor modal from the Kendo grid on my site. The problem that I have run into is that I can't find a way to access any of the variables from my model, where I need to pull the link from.

Here is my grid code:

@(Html.Kendo().Grid<AttorneyRequestPendingDeterminationViewModel>(Model.AttorneyRequests)
          .Name("attorneyRequestGrid")
          .DataSource(dataSource => dataSource
              .WebApi()
              .Read(read => read.Action("GetPendingDeterminationQueue", "AttorneyRequests"))
              .Model(model => model.Id(p => p.Id))
              .Update(read => read.Action("DecisionsEdit", "AttorneyRequests"))
              .Update(read => read.Type(HttpVerbs.Post))
              .Events(events => events.RequestEnd("onRequestEnd"))
              .AutoSync(true)
          )
          .Columns(columns =>
          {
              columns.Bound(m => m.CreatedDateDisplay).Title("Date Entered");
              columns.Bound(m => m.LocalId).Title("Local ID");
              columns.Bound(m => m.DefendantName).Title("Name");
              columns.Bound(m => m.OffenseCodeDisplay).Title("Offense Code");
              columns.Bound(m => m.EnteredBy).Title("FQ User ID");
              columns.Bound(m => m.InterviewLocation).Title("Interview Location");
              columns.Bound(m => m.Recommendation).Title("Recommendation");
              columns.Command(m => m.Edit()).Title("Actions");
          })
          .Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("DecisionsTemplate"))
          .Deferred()
          )

<script>
    require(['/Content/js/config.js'], function() {
        require(['jquery', 'lib/kendo/kendo.grid.min', 'lib/kendo/kendo.aspnetmvc.min', 'form-inputs', 'form-submit', 'modal'], function($, kendogrid, kendomvc, FormInputs, FormSubmit, Modal) {
            @Html.Kendo().DeferredScriptsFor("attorneyRequestGrid", false)
        });

        function onRequestEnd(e) {
        }
    });    
</script>


And here is DecisionsTemplate.cshtml:

<fieldset>
    <legend>Decisions</legend>
    <p class ="colossal">
        @Html.Label(m => m.Recommendation)
        <input class="text-box single-line" id="Recommendation" name="Recommendation" type="text" value="" disabled />
    </p>
    <p class="colossal">
        @Html.Label(m => m.Decision)
        @Html.Kendo().DropDownListFor(m => m.Decision).BindTo(@ViewBag.Decisions)
    </p>
    <p class="colossal">
        @Html.Label(m => m.EligibilityOverrideReason)
        @Html.Kendo().DropDownListFor(m => m.EligibilityOverrideReason).BindTo(@ViewBag.EligibilityOverrideReasons)
    </p>
    <p class="colossal">
        @Html.Label(m => m.NotEligibleReason)
        @Html.Kendo().DropDownListFor(m => m.NotEligibleReason).BindTo(@ViewBag.NotEligibleReasons)
    </p>
</fieldset>

In the modal, all fields are null, although I can get them to display using @Html.EditorFor, so I feel like there has to be a way for me to access them. I have tried using Javascript, but it appears to not work in the template. Are there any workarounds for this problem? I'd be happy to supply any further code or information you might need from me.

Thanks,
Danny






Atanas Korchev
Telerik team
 answered on 10 Nov 2014
1 answer
96 views
I have a scheduler that is using:

.AllDayEventTemplate(
    "<div class='asset-task' style='color: black; background-color: #= Color #' title='#= title # \nAsset: #= AssetName # \nOwner: #= OwnerName #'>" +
        "<strong>#= title #</strong>" +
        "<p>" +
            "<strong>Asset: </strong>#= AssetName #" +
            "<br>" +
            "<strong>Owner: </strong>#= OwnerName #" +
        "</p>" +
    "</div>"
)

The width of the task is the width of the grid cell.  Below the task there is a bar that you can click that will take you to the day view.  See attachment "image1".
I want to shrink the width down to display several task.  See attachment "image2"  (This is a doctored image I did in paint)

How can I do this?
Vladimir Iliev
Telerik team
 answered on 10 Nov 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?