Telerik Forums
UI for ASP.NET MVC Forum
2 answers
1,000 views

When I add a new event programmatically:

var scheduler = $("#Scheduler").data("kendoScheduler");
scheduler.dataSource.add(newEvent);

In cases where I do not assign an ID to a new event, the Create method is called instantly upon adding the new event, which is great; no problems there.

When I do assign an ID, the Update event is not fired, which is a bit unexpected. If the new event is moved or resized then the appropriate event is fired, but I would like to immediately call the Update function with the newly added event.

I have tried:

scheduler.dataSource.sync()

...but this does not work; the Update method is not called.

If I dig in to the data itself, pick out the relevant event, and call the update function, for example:

scheduler.data()[1].update()

Still no luck, no update method is called. I'm stumped.

How do I trigger an Update for a newly added event?

#MagiCSS-bookmarklet,html>body #MagiCSS-bookmarklet{display: block;} #MagiCSS-bookmarklet .cancelDragHandle{cursor: default;}
Deactivated the code
Dimitar
Telerik team
 answered on 13 Sep 2017
3 answers
577 views

I used kendo window with my application and I notice that when I resize the browser to smaller size, kendo window overflows. I have set my kendo window size to 1200. How can I make my kendo window responsive?

 

Ivan Zhekov
Telerik team
 answered on 13 Sep 2017
1 answer
460 views

when I UPDATE an existing entity it all works fine, the problem is only when I CREATE\INSERT.

 

Here is the code below please help

 

        <div>
                @*Phone Carrier*@
                @(Html.Kendo().Grid<OSH.Domain.Models.PhoneCarrier.AppPhoneCarrierItem>()
                .Name("CarrierGrid")
                .Columns(columns =>
                {
                    columns.Bound(e => e.PhoneCarrierId).Width(350).Hidden();
                    columns.Bound(e => e.PhoneCarrier).Width(350);
                    columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); });
                })
                .ToolBar(toolbar => { toolbar.Create().Text("Add New Carrier"); })
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Sortable()
                .Pageable()
                .Scrollable()
                .ColumnMenu()
                .Filterable()
                .HtmlAttributes(new { style = "height:420px;" })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(10)
                    .Model(model => model.Id(p => p.PhoneCarrierId))
                    .Read(read => read.Action("readCarrier", "Admin"))
                    .Create(update => update.Action("CreateCarrier", "Admin"))
                    .Update(update => update.Action("EditCarrier", "Admin"))
                    .Destroy(update => update.Action("DeleteCarrier", "Admin"))
                    .Events(events => events.Error("onError3").Sync("sync_handler"))
                    )
                .Pageable(x => x.PageSizes(new List<object> { 5, 10, 15, 20, "all" }).Refresh(true))
                .Resizable(resize => resize.Columns(true))
                .Reorderable(reorder => reorder.Columns(true))
                )
            </div>

 <div>
                @*Phone Number*@
                @(Html.Kendo().Grid<OSH.Domain.Models.PhoneNumber.AppPhoneNumberItem>()
                .Name("PhoneNumberGrid")
                .Columns(columns =>
                {
                    columns.Bound(e => e.PhoneNumber);
                    columns.Bound(e => e.Description);
                    //columns.Bound(e => e.PhoneNumberTypeId);
                    //columns.Bound(e => e.PhoneCarrierId);
                    columns.ForeignKey(e => e.PhoneNumberTypeId, (System.Collections.IEnumerable)ViewData["PNType"], "PhoneNumberTypeId", "PhoneNumberType")
                   .Title("Phone Number Type");
                    columns.ForeignKey(e => e.PhoneCarrierId, (System.Collections.IEnumerable)ViewData["PhoneCarrier"], "PhoneCarrierId", "PhoneCarrier")
               .Title("Phone Carrier");
                    columns.ForeignKey(e => e.LocationId, (System.Collections.IEnumerable)ViewData["Location"], "LocationId", "LocationName")
               .Title("Location");
                    //columns.Bound(e => e.LocationId);
                    columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); });
                })
                .ToolBar(toolbar => { toolbar.Create(); })
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Sortable()
                .Pageable()
                .Scrollable()
                .ColumnMenu()
                .Filterable()
                .HtmlAttributes(new { style = "height:420px;", data_value_primitive = "true" })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(10)
                    .Model(model => model.Id(p => p.PhoneCarrierId))
                    .Read(read => read.Action("readPhoneNumber", "Admin"))
                    .Create(update => update.Action("CreatePhoneNumber", "Admin"))
                    .Update(update => update.Action("EditPhoneNumber", "Admin"))
                    .Destroy(update => update.Action("DeletePhoneNumber", "Admin"))
                    .Events(events => events.Error("error_handler").Sync("sync_handler"))
                    )
                .Pageable(x => x.PageSizes(new List<object> { 5, 10, 15, 20, "all" }).Refresh(true))
                .Events(e => e.Edit("onPhoneNumberGridEdit").Save("onSavingPhoneNumber"))
                .Resizable(resize => resize.Columns(true))
                .Reorderable(reorder => reorder.Columns(true))
                )
            </div>
        </div>

 

  function onSelect(e) {
                var x = e.item;
                var tabSelectedIndex = $(x).index();
                if (tabSelectedIndex == 2) {
                    $.ajax({
                        url: '@Url.Action("UpdateNewDataType", "Admin")',
                        cache: false,
                        type: 'GET',
                        success: function (Newdata) {
                            var data = [];
                            for (var i = 0; i < Newdata.length; i++) {
                                data.push({ text: Newdata[i].PhoneNumberType, value: Newdata[i].PhoneNumberTypeId });
                            }
                            var grid = $("#PhoneNumberGrid").data("kendoGrid");
                            grid.columns.filter(function (item) {
                                return item.field === "PhoneNumberTypeId";
                            }).forEach(function (item) {
                                item.values = data;
                            });
                            grid.setOptions({ columns: grid.columns, toolbar: [{ name: "create", text: "Add Phone Number" }] });
                            grid.refresh();
                        }
                    });


                    $.ajax({
                        url: '@Url.Action("UpdateNewDataCarrier", "Admin")',
                        cache: false,
                        type: 'GET',
                        success: function (Newdata) {
                            var data = [];
                            for (var i = 0; i < Newdata.length; i++) {
                                data.push({ text: Newdata[i].PhoneCarrier, value: Newdata[i].PhoneCarrierId });
                            }
                            var grid = $("#PhoneNumberGrid").data("kendoGrid");
                            grid.columns.filter(function (item) {
                                return item.field === "PhoneCarrierId";
                            }).forEach(function (item) {
                                item.values = data;
                            });
                            grid.setOptions({ columns: grid.columns, toolbar: [{ name: "create", text: "Add Phone Number" }] });
                            grid.refresh();
                        }
                    });
                }

            }

 

function onSavingPhoneNumber(e) {
            $("#PhoneNumberGrid tbody [data-role=dropdownlist]").each(function () {
                var ddl = $(this).data("kendoDropDownList");
                if (ddl) {
                    var v = ddl.value();
                    var p = ddl.list.attr('id').replace('-list', '');
                    if (p) e.model.set(p, v);
                }
            })

----------------------------------------------------------------------------------------------------------------------------

Controller

 

   public ActionResult EditPhoneNumber([DataSourceRequest] DataSourceRequest request, AppPhoneNumberItem AppPhoneNumberItem)
        {
            PhoneNumberUpdateResponse response = new PhoneNumberUpdateResponse();
            if (AppPhoneNumberItem != null && ModelState.IsValid)
            {
                PhoneNumberRequest request2 = new PhoneNumberRequest();
                request2.PhoneNumberId = AppPhoneNumberItem.PhoneNumberId;
                request2.PhoneNumber = AppPhoneNumberItem.PhoneNumber;
                request2.Description = AppPhoneNumberItem.Description;
                request2.PhoneNumberTypeId = AppPhoneNumberItem.PhoneNumberTypeId;
                request2.PhoneCarrierId = AppPhoneNumberItem.PhoneCarrierId;
                request2.LocationId = AppPhoneNumberItem.LocationId;
                response = phoneNumberApi.UpdatePhoneNumber(request2);
                if (response.Error != null)
                {
                    ErrorLogRequest errorReq = new ErrorLogRequest()
                    {
                        LogDate = DateTime.Now,
                        LogMethod = "UpdatePhoneNumber",
                        LogPage = "Admin",
                        LogPerson = User.Identity.Name,
                        LogInfo = response.Error.ErrorCode + " " + response.Error.ErrorMessage + " " + response.Error.ExceptionObject.Message
                    };
                    apiErrorLog.InsertErrorLog(errorReq);
                }
            }
            BindViewBag();
            return Json(new[] { response }.ToDataSourceResult(request, ModelState));
        }

 

public void BindViewBag()
        {

 ViewData["PhoneCarrier"] = PhoneCarrier;
            ContactTypeRequest request4 = new ContactTypeRequest();
            var ContactType = contactTypeApi.GetContactTypeList(request4).data.Select(p => new AppContactTypeItem()
            {
                ContactTypeId = p.ContactTypeItem.ContactTypeId,
                ContactType = p.ContactTypeItem.ContactType
            });

}

Stefan
Telerik team
 answered on 13 Sep 2017
1 answer
710 views
In this example, the filename is hardcoded.  Is it possible to dynamically change the filename? For example add current date/time.
Preslav
Telerik team
 answered on 12 Sep 2017
2 answers
469 views

I have added a view to my scheduler:

@(Html.Kendo().Scheduler<MyEventViewModel>()
                .Name("Scheduler")
                .Views(v => {
                    v.DayView();
                    v.WeekView();
                    v.CustomView("MyCustomView");
                })

...and so on

...and I have defined this custom view as follows:

var MyCustomView = kendo.ui.MultiDayView.extend({
    options: {
        selectedDateFormat: "{0:D} - {1:D}",

        title: "this does not work"

    },
     title: "this does not work, either",
    calculateDateRange: function () {
        var start = this.options.date,
            idx, length,
            dates = [];
        for (idx = 0, length = 14; idx < length; idx++) {
            dates.push(start);
            start = kendo.date.nextDay(start);
        }
        this._render(dates);
    }
})

But I cannot seem to provide a title to this view to appear on the button. Specifying a title either in the view config, or the options of the view config does not work, and the CustomView method takes only one argument. I believe the javascript equivalent takes two arguments, with one being the title of the custom view, but the MVC version does not. ...so where do I set the title?

Dimitar
Telerik team
 answered on 12 Sep 2017
1 answer
476 views

Hello,

I'm looking for add a target blank to an url but i wonder how to do it:

        @(Html.Kendo().TreeView()
        .Name("treeview-right")
        .DragAndDrop(true)
        .Items(treeview =>
        {

            treeview.Add().Text("Accès Mirakl")
                          .Url("http://google.com")
                          .ImageUrl(Url.Content("~/Content/images/internet_16x16.png"));

            treeview.Add().Text("Wiki Mirakl")
                          .Url("http://goole.fr")
                          .ImageUrl(Url.Content("~/Content/images/ampoule_16x16.png"));
        })

Neli
Telerik team
 answered on 12 Sep 2017
1 answer
651 views

Hi,

In Kendo Grid - Export to Excel, is there any way to set the format of an excel column. I need to set the date format to "dd-MMM-yyyy" for transaction date column instead of using default format.


I am using server side grid

Stefan
Telerik team
 answered on 12 Sep 2017
1 answer
117 views

Hi,

We are having problems with paging on a grid when using server side paging.

We have a grid that contains, for example, 500 items. We have this paged to show 6 items and are currently looking at page 7.

On the back end, the data has been updated so that there is now only a single record in the dataset.

When I now do a refresh of the grid, the results are as follows:

The DataSourceRequest is as follows: Page = 7, PageSize = 6, all other properties are 0.

After performing ToDataSourceResult(request), the DataSourceResult is as follows: Data = empty, Total = 1.

Once this is returned, the grid then shows the no data template.

Is this a bug, or is there a way to fix it. I can obviously detect this, modify the request parameters and re-generate the DataSourceResult, but this smells a bit.

Thanks in advance,

Carl

Stefan
Telerik team
 answered on 12 Sep 2017
4 answers
704 views

Hi,

 

in a DDL I display entries of the following type:

public class ConfigEntryLine {
        public long ItemID { get; set; }
        public string ItemText { get; set; }
 
        [DisplayFormat(DataFormatString = "{0:c}")]
        public double ItemPrice { get; set; }

In the dropdown I want to display the"ItemPrice" on the right side formatted like given in the attribute on the model.

I use the DDL like in a editfor like this:

...
else {
    @(Html.Kendo().DropDownListFor(m => m.SelectedID)
                .DataTextField("ItemText")
                .DataValueField("ItemID")
                .AutoBind(true)
                .HtmlAttributes(new { style = "width:280px;font-size:small" })
                .ValuePrimitive(true)
                .BindTo(Model.Lines)
                 .Template("<span class=\"k-state-default\">#: data.ItemText#</span><span class=\"k-state-default pull-right\"><strong>#: data.ItemPrice#</strong>")
                );
}

I get the value - as number without decimal places and currency sign.

Is it possible to use the DisplayFormat attribute in a DDL template?

Heli
Top achievements
Rank 2
 answered on 11 Sep 2017
4 answers
467 views

When I create a new appointment on the calendar, the default end time is 30 minutes after the selected start time. Is there a way to change the default end time to be 2 hours after the selected start time.

Essentially I want to change the default appointment duration from 1/2 hour to 2 hours.

Thanks

Pete
Top achievements
Rank 1
 answered on 08 Sep 2017
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
DropDownButton
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?