Telerik Forums
UI for ASP.NET MVC Forum
1 answer
168 views
How do you autosize the map so it takes up the full 100% of the div and will resize auto.
Preslav
Telerik team
 answered on 26 Dec 2017
1 answer
318 views

I am trying to use popup editing with a grid that uses <dynamic> so that I can pass in any model and re-use it.I was able to reproduce my issue by editing the "editing_popup.cshtml" file in the "Kendo.MvcExamples" solution.

 

Notice that I explicitly told the template "ProductViewModel" to be used. Initally it wasn't using that template, until I moved it into Views\Shared\EditorTemplates. But once I did I got the same error I get from my own project:

 

Inner Exception: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Object', but this dictionary requires a model item of type 'Kendo.Mvc.Examples.Models.ProductViewModel'.

 

I understand WHY, I'm getting this error; the grid basically treats dynamic as an object and that is what is being sent to the viewmodel's template ("ProductViewModel.cshtml"). My question, is is there someway I can get around it, even if I have to pass in a "Type" object.

 

@(Html.Kendo().Grid<dynamic>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound("ProductName");
        //columns.Bound(p => p.ProductName);
        //columns.Bound(p => p.UnitPrice).Width(120);
        //columns.Bound(p => p.UnitsInStock).Width(120);
        //columns.Bound(p => p.Discontinued).Width(120);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ProductViewModel"))
    .Pageable()
    .Sortable()
    .Scrollable()
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Events(events => events.Error("error_handler"))
        //.Model(model => model.Id(p => p.ProductID))
        .Model(model => model.Id("ProductID"))
        .Create(update => update.Action("EditingPopup_Create", "Grid"))
        .Read(read => read.Action("EditingPopup_Read", "Grid"))
        .Update(update => update.Action("EditingPopup_Update", "Grid"))
        .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
    )
)
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
</script>
Boyan Dimitrov
Telerik team
 answered on 22 Dec 2017
5 answers
354 views

Hi, I've looked through all the similar support questions and answers regarding adding custom fields to the Scheduler Editor. I've downloaded the sample MVC projects (SchedulerCustomViewDemo) and it looks straightforward. I'm missing something basic because I cannot get a custom text field or check box to populate the Model when editing a Scheduled Event or creating a new one. I've added the fields to the database, refreshed the EF6 edmx, and added them to my ViewModel. Since these fields are not populated in the model, they don't get saved to the db on create or edit. 

For example i have a textarea field called Summary that I add to the editor by modifying the CustomEditorTemplate.html (I just copied CustomEditorTemplate.html into my project, leaving all fields as they were and adding my own):

 

<div class="k-edit-label">
    @(Html.LabelFor(model => model.Summary))
</div>
<div data-container-for="summary" class="k-edit-field">
    @(Html.TextAreaFor(model => model.Summary, new { @class = "k-textbox", data_bind = "value:summary" }))
</div>

for a checkbox I do this:

<div class="k-edit-label">
    @(Html.LabelFor(model => model.IsPublished))
</div>
<div data-container-for="isPublished" class="k-edit-field">
    <input data-bind="checked: isPublished" data-val="true" id="IsPublished" name="IsPublished" type="checkbox" />
</div>

These new fields show up fine but how do i get these bound to the model so that the call to:

public virtual JsonResult EventSchedule_Create([DataSourceRequest] DataSourceRequest request, EventScheduleViewModel evt)

 

fills the EventScheduleViewModel properly?

 

Love the way theScheduler handles the recurring events but stymied on the databinding. The fields that came in the sample project (Title, Start, End, isAllDay etc. bind properly, just not my custom ones...

 

Thanks.


Dimitar
Telerik team
 answered on 22 Dec 2017
4 answers
1.3K+ views

Hi,

The items in my drop down list are quite long - is there a way of wrapping the text in the options used within the dropdown list so that all the text can be displayed?

If so, is there also a way of indenting the "wrapped" lines (all except the first line)?

I was able to do this in chosen.js, but would I am using the telerik dropdown in this instance due to it's virtualisation capabilities.

Regards,

Sean

Dimitar
Telerik team
 answered on 21 Dec 2017
1 answer
159 views
When we were using kendoui for jquery the last menuitem always got a k-last added to it .... in migrating to razor that same functionality doesn't work 
Ivan Danchev
Telerik team
 answered on 21 Dec 2017
3 answers
112 views

I have set up a asp.net MVC web app and in the layout.cshtml I set a mobilelayout and mobiletabstrip.  The mobile application's server navigation has been set to false, so that the partial views are obtained from the controller via ajax but they are only gotten once (never refreshed).  I have set a couple of events on the view for before show and was thinking that I could go and grab the latest partial view from the controller here.

Is this process a good idea or is there a better way?

Veselin Tsvetanov
Telerik team
 answered on 20 Dec 2017
3 answers
240 views

I am getting error after i integrated Cube to Pivotgrid in cshtml. however, cube is producing result in excel when i tried. please see attached image for error and excel result generated from cube.

this is the major piece my manager is looking before he approves Telerik license budget and i have only 3 days left to trial version.

please help ASAP.

here is the code.

 

    @(Html.Kendo().PivotConfigurator()
.Name("configurator")
.HtmlAttributes(new { @class = "hidden-on-narrow" })
.Filterable(true)
.Sortable()
.Height(580)
    )
 
    @(Html.Kendo().PivotGrid()
.Name("pivotgrid")
.ColumnWidth(200)
.Height(580)
.HtmlAttributes(new { @class = "hidden-on-narrow" })
.Filterable(true)
.Sortable()
.Configurator("#configurator")
.DataSource(dataSource => dataSource.
    Xmla()
    .Columns(columns =>
    {
        columns.Add("[Incident].[Status]").Expand(true);
        
    })
    .Rows(rows => rows.Add("[Clients].[Id]"))
    .Measures(measures => measures.Values(new string[] { "[Measures].[Incident Count]" }))
    .Transport(transport => transport
        .Connection(connection => connection
             .Catalog("NextGenToolIncidentCube")
                    .Cube("[IncidentAnalyticalCube"))
        .Read(read => read
            .Url("http://xxxxxxxxxxx/OLAP/msmdpump.dll")
            .DataType("text")
            .ContentType("text/xml")
            .Type(HttpVerbs.Post)
        )
    )
    .Events(e => e.Error("onError"))
)
    )
Preslav
Telerik team
 answered on 19 Dec 2017
1 answer
250 views

Propagating Page properties of a server generated "Telerik.Windows.Documents.Spreadsheet.Model.Workbook" in a web rendered "Telerik.Web.Spreadsheet.Workbook"

 

Heads up, this is only for licensed developers who can access the commercial library source code.

 

At present the documents.spreadsheet workbook has a richer capacity than a web.spreadsheet workbook, especially around page setting.  I don't know the roadmap, but expect at some point the web Spreadsheet component will take on a richer feature set that aligns with Excel application.

A Telerik document workbook is converted to it's web version for viewing in a browser by using the FromDocument() method.  The features that are lost from the sheets of the original document workbook include:

  • page orientation
  • margins
  • scaling
  • headers and footers

The listed items are those I wanted to deal with, there may be more but they were of no concern to me at this time.

My project has a Controller/ViewModel

Telerik.Windows.Documents.Spreadsheet.Model.Workbook serverSideModel;
... lots of serverSideModel method calls that create a spreadsheet, including page settings ...
return View(serverSideModel);

 

and a View

@model Telerik.Windows.Documents.Spreadsheet.Model.Workbook
...
@(
    Html.Kendo().Spreadsheet()
    .Name("mySpreadsheet")
    .BindTo(Telerik.Web.Spreadsheet.Workbook.FromDocument(Model))  //  <--- convert to web version for viewing in browser
    ...
    )

 

At this point the Spreadsheet component in the browser will display the spreadsheet that was created server side.

The component has a download button and you can select to download as an .xlsx.

The downloaded Excel will have lost any page properties that were in the original server side Telerik document.  This is because the internal javascript for creating the excel download does not render any Excel xml related to page layout.

 

Why not?
Because web spreadsheet model does not implement page setup features. The FromDocument() conversion works, but all the page properties info in the document spreadsheet is ignored.

How can this be remedied ?
1. Explicitly add the original pageSetup features to the converted object.
2. Modify library source code to render pageSetup features in the Excel xml that becomes the download.

 

Step 1.
After the web spreadsheet (as a FromDocument) is rendered, the document page properties can be explicitly reattached by code in a kendo.syncReady funtion.
For example, at bottom of the View, add a script block:

<script>
    kendo.syncReady(function () {
 
        var book = $("#mySpreadsheet").data("kendoSpreadsheet");
 
        @for (var index=0; index < Model.Sheets.Count; index++)
        {
            var sheet = Model.Worksheets[index];
            var pageSetup = sheet.WorksheetPageSetup;
            var left = (pageSetup.Margins.Left > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Left)) : pageSetup.Margins.Left;
            var right = (pageSetup.Margins.Right > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Right)) : pageSetup.Margins.Right;
            var top = (pageSetup.Margins.Top > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Top)) : pageSetup.Margins.Top;
            var bottom = (pageSetup.Margins.Bottom > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Bottom)) : pageSetup.Margins.Bottom;
            var header = (pageSetup.Margins.Header > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Header)) : pageSetup.Margins.Header;
            var footer = (pageSetup.Margins.Footer > 4) ? UnitHelper.DipToInch(UnitHelper.PointToDip(pageSetup.Margins.Footer)) : pageSetup.Margins.Footer;
            var orientation = (pageSetup.PageOrientation == Telerik.Windows.Documents.Model.PageOrientation.Landscape) ? "Landscape" : "Portrait";
            var scale = pageSetup.ScaleFactor.Width * 100;@* convert from telerik scaleFactor to excel scale % *@
        <text>
        book.sheets()[@index].showGridLines(false);
        book.sheets()[@index].pageSetup = {
                viewTags: 'view="pageBreakPreview" zoomScaleNormal="85" zoomScaleSheetLayoutView="100"',  // I know the innards of Excel xml enough to to this.  I did not want to deal making changes in the library source that handled view, zoomScalNormal and zoomScaleSheetLayoutView as actual properties
                margins: {
                    left: @left,
                    right: @right,
                    top: @top,
                    bottom: @bottom,
                    header: @header,
                    footer: @footer},
                orientation: "@(orientation.ToLower())",
                scale: @scale,
                headerFooterSettings: {
                    header: {
                        leftSection: {
                            text: "@pageSetup.HeaderFooterSettings.Header.LeftSection.Text"
                        },
                        centerSection: {
                            text: "@pageSetup.HeaderFooterSettings.Header.CenterSection.Text"
                        },
                        rightSection: {
                            text: "@pageSetup.HeaderFooterSettings.Header.RightSection.Text"
                        }
                    },
                    footer: {
                        leftSection: {
                            text: "@pageSetup.HeaderFooterSettings.Footer.LeftSection.Text"
                        },
                        centerSection: {
                            text: "@pageSetup.HeaderFooterSettings.Footer.CenterSection.Text"
                        },
                        rightSection: {
                            text: "@pageSetup.HeaderFooterSettings.Footer.RightSection.Text"
                        }
                    }
                }
 
        };
        </text>
        }
@*
        replace standard download button response of a Export... dialog
        with a direct download as Excel
*@
        $("#mySpreadsheet .k-i-download")
            .parent(".k-button")
            .unbind()
            .on("click", function (e) {
                $("#mySpreadsheet").data("kendoSpreadsheet").saveAsExcel();
            return false;
        });
    });
</script>

 

Step 2. Modify kendo.all.js

This is for licensed developers only.

Patch your licensed copy of the commercial library source code (v 2017.3.1026) with the attached patch file.

The view must include the modified library code that has been copied into your asp-net mvc project, and can not use the minified cdn version.  The original licensed kendo-ui complete library source code can be downloaded from your account login.

Myview.cshtml

...
    <script src="~/Scripts/kendo/2017.3.1026/js/kendo.all.js"></script>  // modified version contains new magic
...

V

 Now when you download your richly featured server side generated spreadsheet from the view it will still contain those rich features.
   


Veselin Tsvetanov
Telerik team
 answered on 19 Dec 2017
5 answers
446 views
Hi,

In order to have the same functionality in treelist as in grid we have create a new file where we copied the treelist code and added the required functionality. Now we are thinking maybe we should create a new widget derived from treelist and add the extra functionality. (see https://www.telerik.com/forums/treelist-conditional-filter-functionality and/or https://www.telerik.com/forums/visibility-button-widget---share-code-review!-!)

Since we are using the MVC we were wondering: Can we easily create an MVC wrapper for the new widget? Maybe derived from the treelist wrapper, and just change the widget name to use the new widget name instead of the kendotreelist?

Thank you
Alexandra
Alex Hajigeorgieva
Telerik team
 answered on 18 Dec 2017
2 answers
1.2K+ views

Scenario:

I have a Grid, and a column with text, with inline editing and OnChange event.

User Clicks a cell and the OnChange event it fired

Once clicked, a modal window is opened (Standard Bootstrap)

Question:

How do I update that Cell again from the Modal. How do I pass the ID or context of the Cell down the stack to the Modal Window?

I have seen there is a TR data-uid, but I'm not sure how to get it in the click event or how to select it with the api down the road in the modal.

Stefan
Telerik team
 answered on 18 Dec 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?