Telerik Forums
UI for ASP.NET MVC Forum
6 answers
396 views
Currently I have a grid that I am trying to have a drop down list appear in one of the columns while in Edit mode using the ForeignKey column.

@(Html.Kendo().Grid<Inspection>()
                .Name("grid")
                .DataSource(dataSource => dataSource.Ajax()
                .Model(model =>
                {
                    model.Id(p => p.ID);
                    model.Field(p => p.Date);
                    model.Field(p => p.TypeID);
                })
                 .Read(read => read.Action("grid_Read", "Grid", new { ID = Model.ID }))
                .Update(update => update.Action("grid_Update", "Grid", new { ID = Model.ID }))
                .PageSize(10))
                .Columns(columns =>
                {
                    columns.Bound(c => c.RequestedDate).Format("{0:d}").EditorTemplateName("_DateTime").Width(200);
                    columns.ForeignKey(c => c.TypeID, (System.Collections.IEnumerable)ViewBag.Types, "TypeID", "TypeName").Title("Test Types");
 
                    columns.Command(command => { command.Edit(); });
                })
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Pageable(pageable => pageable.Messages(messages => messages.Empty("Nothing Here")))
                .Sortable(sortable => sortable.AllowUnsort(false))
            )


The grid loads with all the correct data, and even shows the TypeName name while in Read mode. However, when switching to Edit mode the column shows the TypeID in a text box, not a drop down list. The code to populate the ViewBag is below

ViewBag.Types = _service.Repository.InspectionTypes;


All the data appears to end up on the page - when inspecting the editable element the list of options appears in a jQuery script, however, they do not populate a drop down while editing.

The code matches the Kendo MVC demo as much as possible, so am I missing something? Are there certain constraints that need to be met?
Vladimir Iliev
Telerik team
 answered on 28 Sep 2015
1 answer
211 views

Hi,

 I need to be able to show some notifications that auto hide after 5 seconds and others that don't auto hide.  I am achieving this by using this code when I want to show a notification for 5 seconds:

 

01.var fadingnotification = $("#fadingnotification").kendoNotification({
02.    position: {
03.        pinned: true,
04.        bottom: 60,
05.        right: 30
06.    },
07.    stacking: "up",
08.    autoHideAfter: 5000,
09.    templates: [{
10.            type: "stickyinfonodismiss",
11.            template: $("#stickyInfoNoDismissTemplate").html()
12.        }, {
13.            type: "stickyinfo",
14.            template: $("#stickyInfoTemplate").html()
15.        }, {
16.            type: "info",
17.            template: $("#infoTemplate").html()
18.    }]
19.}).data("kendoNotification");
20. 
21.fadingnotification.show({
22.    message: msgToDisplay
23.}, "info");

and using the same code but with "autoHideAfter: 0" for the ones that I want to display without hiding.

 The problem I have is that this effectively initiates a new notification GUID each time so the notifications start again at the bottom of the screen each time even if there are already notifications on screen.

 Ideally I want to just change the autoHideAfter option without initialising a new notification and therefore a new GUID.

Any ideas?

Thanks,

Mark.

Plamen Lazarov
Telerik team
 answered on 25 Sep 2015
3 answers
365 views

I've following grid with inline edit. For selecting date and time they have their respective date and time controls. I want to post date in '12-Sep-2015 12.00.00' format and time in '09:00:00' format to mvc control action. But when I post the data, date is in the 'Wed Sep 23 2015 00:00:00 GMT-0400 (Eastern Daylight Time)' format. Time is in the 'Sat Sep 19 2015 15:00:00 GMT-0400 (Eastern Daylight Time)' format. This only happens if I change date and time value. If I don't change, values are posted the way I want to. What do I do to post data in proper format after edit?

 

@(Html.Kendo().Grid<Kyklos.ClinicPortal.ViewModels.AppointmentViewModel>()
            .Name("UpCmgApptGrid").
            Columns(columns =>
            {                
                columns.Bound(c => c.strAppintmentDate).Title("Appintment Date").Format("{0:MM/dd/yyyy}").EditorTemplateName("Date");
                columns.Bound(c => c.strAppintmentTime).Title("Appintment Time").Format("{0:hh:mm tt}").EditorTemplateName("Time");
                columns.Bound(c => c.DoctorName).Title("Doctor");
                columns.Command(command => { command.Edit(); }).Title("Edit").Width(250);
                columns.Command(command => { command.Destroy(); }).Title("Delete").Width(150);
            })
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Pageable()
            .Sortable()
            .Scrollable()
            .Events(events => events.Cancel("onCancel"))
            .DataSource(
                dataSource => dataSource
                    .Ajax()
                    .Model(model =>
                    {
                        model.Id(a => a.PatAppointment.AppointmentId);
                        model.Field(a => a.DoctorName).Editable(false);
                    })
                    .Read("UpcomingAppointment_Read", "Appointment", new { PatientId = Model.PatAppointment.PatientId })
                    .Update(update => update.Action("UpcomingAppointment_Update", "Appointment"))
                    .Destroy(update => update.Action("UpcomingAppointment_Destroy", "Appointment"))
            )
)​

Boyan Dimitrov
Telerik team
 answered on 25 Sep 2015
1 answer
180 views

Hi I have problem with export diagram to SVG.

I get error message:

This page contains the following errors: error on line 1 at column 3494: EntityRef: expecting ';'
Below is a rendering of the page up to the first error.​

I tried kendo version 2015.2.624 and v2015.2.902. The result is the same.

I tried this code:

$("#exportSvg").click(function () {
            var diagram = $("#diagram").getKendoDiagram();
            diagram.exportSVG().done(function (data) {
                kendo.saveAs({
                    dataURI: data,
                    fileName: "diagram.svg"
                });
            });
        });

and this code with proxyURL:

$("#exportSvg").click(function () {
            var diagram = $("#diagram").getKendoDiagram();
            diagram.exportSVG().done(function (data) {
                kendo.saveAs({
                    dataURI: data,
                    fileName: "diagram.svg",
                    proxyURL: "<%= Url.Action("ExportSave", "OrganizacneSchemy") %>"
                });
            });
        });​ 

 

Where is the problem ? 

Thanks

Daniel
Telerik team
 answered on 25 Sep 2015
10 answers
419 views

I am adding MVC & Telerik Kendo to legacy webforms application.

I have only just added MVC 5 itself to the project using an MVC area. (see http://www.davepaquette.com/archive/2013/12/30/so-you-inherited-an-asp-net-web-forms-application.aspx).

To add Telerik MVC, I am following the steps here: http://docs.telerik.com/kendo-ui/aspnet-mvc/asp-net-mvc-5

 When I get to the step adding @(Html.Kendo().DatePicker().Name("datepicker")) to a "hello world" mvc, and try to access it, I get a "System.EntryPointNotFoundException".

 Any ideas what could be wrong?

 Additional info:  

 I made the web.config changes to (and only to) the web.config file in the MVC area.

 The "~/Content/kendo/..." and "~/Scripts/kendo/..." are in their standard places, not in the MVC area.  Not sure if this matters, but no errors appear to be generated by the telerik bundles in BundleConfig.vb.

Googling I have found mentions of <bindingredirects> in the web.config, but the Telerik instructions I am following to not mention this possibility.

Atanas Korchev
Telerik team
 answered on 25 Sep 2015
4 answers
438 views

Hi,

I need to bind the datasource to ASP.NET MVC Scheduler dynamically. In my scenario, I have 5 dropdownlists. Users will select item from the dropdownlists and then click Search buton and the scheduler will load the result. How can I do that with javascript? 

 

Please see the attached image.

 

@(Html.Kendo().Scheduler<TaskViewModel>()
    .Name("schedulerJob")
    .Date(new DateTime(2015, 8, 31))
    .StartTime(new DateTime(2015, 8, 31, 7, 00, 00))
    .Height(600)
    .Views(views =>
    {
        views.TimelineView();
    })
    .Timezone("Etc/UTC")
    .Group(group => group.Resources("Techs").Orientation(SchedulerGroupOrientation.Vertical))
    .Resources(resource =>
    {
        resource.Add(m => m.TechName)
            .Title("Techs")
            .Name("Techs")
            .DataTextField("emm_code")
            .DataValueField("emm_code")
            .DataSource(d => d.Read("Techs", "JOBS"));
    })
    .DataSource(d => d
        .Model(m =>
        {
            m.Id(r => r.emm_code);
        })
        .Read("JobSchedule_Read", "JOBS")
        .Create("JobSchedule_Create", "JOBS")
        .Update("JobSchedule_Update", "JOBS")
        .Destroy("JobSchedule_Delete", "JOBS")
    )
)

 

  

public JsonResult JobSchedule_Read([DataSourceRequest] DataSourceRequest request)
{
    DateTime startDateTime;
    DateTime endDateTime;
    List<JscDet> JscDet = (List<JscDet>)Session["JobScheduleDateTime"];
    List<TaskViewModel> tasks = new List<TaskViewModel>();
 
    foreach (var item in JscDet)
    {
        startDateTime = SchedulerUtility.GetDateTimeFromSeconds(item.jsd_sch_date, item.jsd_sch_start_time);
        endDateTime = SchedulerUtility.GetDateTimeFromSeconds(item.jsd_sch_date, item.jsd_sch_end_time);
        tasks.Add(new TaskViewModel()
        {
            TaskID = item.jsd_jobno,
            TechName = item.jsd_sch_assto,
            emm_code = item.jsd_sch_assto,
            Title = "Job Title",
            Start = new DateTime(startDateTime.Year, startDateTime.Month, startDateTime.Day, startDateTime.Hour, startDateTime.Minute, startDateTime.Second),
            End = new DateTime(endDateTime.Year, endDateTime.Month, endDateTime.Day, endDateTime.Hour, endDateTime.Minute, endDateTime.Second),
            Description = "Description 101",
            IsAllDay = false
        });
    }
 
    return Json(tasks.ToDataSourceResult(request));
}

Thanks in advance

Kevork
Top achievements
Rank 2
 answered on 24 Sep 2015
2 answers
93 views

I have this multiselect on my asp.net mvc project

 

  <div class="demo-section user-selection">
      <h3 class="title">1. Select one or more Users</h3>
      @(Html.Kendo().MultiSelect()
.Name("customers")
.DataTextField("givenName")
 
    .DataValueField("description")
    //.Placeholder("No users selected")
    .Events(events => events.Change("NewSelection"))
 
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCustomers", "Home");
        });
    })
    .Height(300)
                    //.HtmlAttributes(new { style = "width: 400px" })
                    .HeaderTemplate("<div class=\"dropdown-header dropdown_Users\">" +
                          "<span class=\"k-widget k-header\">Photo</span>" +
                          "<span class=\"k-widget k-header\">Contact info</span>" +
                      "</div>")
                                                    .ItemTemplate("<span class=\"k-state-default item-user userPic\"><img class=\"userPhoto\" src=\"" + @System.Configuration.ConfigurationManager.AppSettings["BaseUrl"] + "user/image?userIid=#:data.IID#\" /></span>" +
                                                              "<span class=\"k-state-default item-user \"><h3>#: data.givenName # #: data.sn #</h3><p>#: data.description #</p></span>")
      )
  </div>

 

the data i load is of 2000 users that then appear in the multiselect list with their photo, first and last name and role.

my problem is that the loading takes about 5 or 6 seconds, and when scrolling down the list it sometimes gets a bit "clunky"
.

Is there anyway to improve the loading of data maybe making it load in blocks of 200 users at a time , or another way of improving performance?

Ric
Top achievements
Rank 1
 answered on 24 Sep 2015
2 answers
259 views
I have a hierarchical grid which is rendering fine except that the date formatting for the detail grid is being ignored and a JSON date is being rendered instead.  The same formatting works fine in the Master grid.  Data for the sub-grid comes from a List collection in the object that populates the master.  The data was returned as one List of objects.

The detail grid renders
/Date(-62135568000000)/
instead of something like
01/23/2013 04:43 PM
Here's the code:
@model IEnumerable<KUI_CS_Test1.ROAMHostSvc.BatchHeader>
 
@{
    ViewBag.Title = "Kendo UI for MVC (C#) Test App";
}
 
<h2>Batch List</h2>
@(Html.Kendo().Grid(Model)
    .Name("batchGrid")
    .Sortable()
    .Pageable()
    .Filterable()
    .Columns(columns =>
        {
            columns.Bound(b => b.BatchID)
                                    .Width("200");
            columns.Bound(b => b.Transmitted_DateTime)
                                    .Width("15")
                                    .Format("{0:MM/dd/yyyy hh:mm tt}")
                                    .Title("Transmitted");
            columns.Bound(b => b.Completed_DateTime)
                                    .Width("15")
                                    .Format("{0:MM/dd/yyyy hh:mm tt}")
                                    .Title("Completed");
            columns.Bound(b => b.Created_DTTM)
                                    .Width("15")
                                    .Format("{0:MM/dd/yyyy hh:mm tt}")
                                    .Title("Created");
            columns.Bound(b => b.Created_Emp_Name)
                                    .Width("18")
                                    .Title("Created By");
        }
    )
    .ClientDetailTemplateId("transactions")
    .Events(e => e.DetailInit("detailInit"))
    .DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("FetchBatchList2", "Home"))
    )
)
 
<script id="transactions" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<KUI_CS_Test1.ROAMHostSvc.TransactionBase>()
                    .Name("Transactions_#=BatchID#")
                    .Columns( columns =>
                    {
                        columns.Bound(t => t.ID)
                                                .Width("200")
                                                .Title("Transaction ID");
                        columns.Bound(t => t.Version)
                                                .Width("10")
                                                .Title("Version");
                        columns.Bound(t => t.TranTypeDisplayText)
                                                .Width("15")
                                                .Title("Tran Type");
                        columns.Bound(t => t.PostingFlagDisplayText)
                                                .Width("15")
                                                .Title("Posting Flag");
                        columns.Bound(t => t.Posting_DTTM)
                                                .Width("15")
                                                .Format("{0:MM/dd/yyyy hh:mm tt}")
                                                .Title("Posting Date/Time");
                        columns.Bound(t => t.PostingMessage)
                                                .Width("300")
                                                .Title("Posting Message");
                    })
                    .ToClientTemplate()
    )
</script>
 
<script type="text/javascript" language="javascript">
    function detailInit(e) {
        var grid = $("#Transactions_" + e.data.BatchID).data("kendoGrid");
        grid.dataSource.data(e.data.TranCollection);
    }
</script>
Boyan Dimitrov
Telerik team
 answered on 24 Sep 2015
1 answer
373 views

 

We are trying to implement kendo grid preserve state functionality. Requirement is a grid state (filter, page etc) is already pre saved in the db and every times page loads, we have to show grid with the pre saved state. We followed the example given in link ( http://www.telerik.com/support/code-library/save-grid-state-in-session-on-server-side ) and able to achieve the requirement in two steps.
 Step 1: Load the page with default grid option

@(Html.Kendo().Grid<TelerikMvcApp1.Models.Product>()
      .Name("grid")
      .DataSource(ds => ds.Ajax().Read("Read", "Home"))
      .Pageable()
      .Groupable()
      .Sortable()
      .Reorderable(r => r.Columns(true))
      .Resizable(r => r.Columns(true))
)

and then,
Step 2: on document ready, make an ajax call , get the pre saved grid options , destroy the existing grid and set the grid options

$(document).ready(function ()
{
    var grid = $("#grid").data("kendoGrid");

    var dataSource = grid.dataSource;

    $.ajax({
        url: "/Home/Load",
        success: function(state) {
            state = JSON.parse(state);

            var options = grid.options;

            options.columns = state.columns;

            options.dataSource.page = state.page;
            options.dataSource.pageSize = state.pageSize;
            options.dataSource.sort = state.sort;
            options.dataSource.filter = state.filter;
            options.dataSource.group = state.group;

            grid.destroy();

            $("#grid")
               .empty()
               .kendoGrid(options);
        }
    });
});


Problems with this approach are

- grid’s data read server side method “Read” is hit twice. One for default load and other for state load.
- Grid shows all records first , then truncates and then shows the data with saved grid options. It does not look good.

Is there any way to apply the grid options first time itself, not on document ready. I want to avoid multiple server side calling and grid data reads.
Boyan Dimitrov
Telerik team
 answered on 24 Sep 2015
2 answers
174 views
Hi,
I implemented Kendo Grid helper in a MVC 4 with WebApi application, but I don't know how can I set de column list to change dinamically the rows that it shows. I don't want put all columns, only a list of columns pre-selects by diferents criterials (user config preferences).

My Helper code:

@(Html.Kendo().Grid<Bitacora.WebUI.Models.WhiteBoard.XXXGridModel>()
            .Name("Grid")
            .AutoBind(true)
            .EnableCustomBinding(true)
            //.BindTo(Model.xxxx.YYYList)
            .Columns(c =>
            {
                c.AutoGenerate(column =>
                {
                    //customize autogenereted column's settings                                                    
                    column.Width = "150px";
                    
                    //column.ClientTemplate = "<input type='checkbox' name='checkbox' />";

                });
            })
            .Scrollable(scrolling => scrolling.Enabled(true).Height("auto"))
            .Resizable(x => x.Columns(true))
            .Events(events => events.Change("searchCalls"))
            .DataSource(dataSource => dataSource
                                                .Ajax()
                                                .Read(read => read
                                                   .Action("Search", "api/ActionApi")
                                                   .Data("getFiltersSelected")
                                                   .Type(HttpVerbs.Post))
                                                   .ServerOperation(true)) // Paging, sorting, filtering and grouping will be done server-side  
                                                //.ColumnMenu()
                                                .Selectable(selectable => selectable
                                                    .Mode(GridSelectionMode.Multiple))
                                                .Reorderable(reorder => reorder.Columns(true))
                                                .Groupable(grouping => grouping.Enabled(true))
                                                .Filterable(filterable => {filterable
                                                                            .Operators(operators => 
                                                                                        {operators.ForString(strFilter => strFilter.Clear().Contains("contains"));
                                                                                            operators.ForNumber(strFilter => strFilter.Clear());
                                                                                        });
                                                                            filterable.Extra(false);
                                                            }) //--> sólo se muestra el contains en las columnas Texto
            .Sortable(s=> s
                .SortMode(Kendo.Mvc.UI.GridSortMode.MultipleColumn)
                .AllowUnsort(true))
            .Pageable(pager => pager
                .Enabled(true)
                .Input(true)
                .PageSizes(new [] { 5, 10, 20, 30, 40, 50 })) // MULTIDIOMA RESOURCES


My Model:

 public class XXXGridModel
    {
        [Display(Name = "Id", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int Id { get; set; }
         [Display(Name = "DateCreated", ResourceType = typeof(WhiteBoardGridVMResource))]
        public DateTime DateCreated { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CallNumber { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string FileNumber { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string DUE { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdBranchOffice { get; set; }
         [Display(Name = "BranchOfficeName", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string BranchOfficeOfficeName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCompany { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CompanyCompanyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdOffice { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OfficeOfficeName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdShip { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string ShipShipName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdPort { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string PortPortName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCallStatus { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CallStatusStatusName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdOwner { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OwnerThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdOperator { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OperatorThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdInductor { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string InductorThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorOwner { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorOperator { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorInductor { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCreatedBy { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CreatedByUserName { get; set; }
        }

Anyone can Help me?!
Thanks in advance
balazs
Top achievements
Rank 2
Iron
 answered on 24 Sep 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?