Telerik Forums
UI for ASP.NET MVC Forum
3 answers
343 views

Hello,

I've been reading up on the documentation about the customisation of exported excel documents from the grid.  My project is an MVC applicaation using razor views.  My question is how do you marry the grid to the javascript so that when the user presses "export" it runs the function?

For example my grid looks like this:

  @(Html.Kendo().Grid<Widget_Tests.Models.tbl_data>()
        .Name("Grid")
        .Columns(columns =>
            {
                columns.Bound(c => c.old_id).Title("Old ID");
                columns.Bound(c => c.name).Title("Name");
                columns.Bound(c => c.type).Title("Vessel Type");
                columns.Bound(c => c.company).Title("Company");        
            }
        )                
        .ToolBar(toolbar =>
            {
                toolbar.Excel();                               
            }
        )
        .Pageable()
        .Scrollable()
        .Excel(excel => excel
            .FileName("MyGrid.xlsx")            
            .AllPages(true)
            .Filterable(true)           
            )
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(50)
            .Read(read => read.Action("tbl_data_Read", "Home"))            
            )            
        )

Here is the javascript I found in the documentation:

  function saveExcel() {
        var workbook = new kendo.ooxml.Workbook({
            sheets: [
              {
                  columns: [{ autoWidth: true }],
                  rows: [
                    {
                        cells: [
                          {
                              value: "bold and italic",
                              bold: true,
                              italic: true
                          }
                        ]
                    },
                    {
                        cells: [
                          {
                              value: "red text on blue background",
                              color: "#ff0000",
                              background: "#0000ff"
                          }
                        ]
                    },
                    {
                        cells: [
                          {
                              value: "Arial 20px",
                              fontSize: 20,
                              fontName: "Arial"
                          }
                        ]
                    },
                    {
                        cells: [
                          {
                              value: "Right aligned",
                              hAlign: "right"
                          }
                        ]
                    },
                    {
                        cells: [
                          {
                              value: "Centered horizontally and vertically",
                              vAlign: "center",
                              hAlign: "center",
                              rowSpan: 2
                          }
                        ]
                    }
                  ]
              }
            ]
        });
    };

kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName: "Test.xlsx"
});

 How do these go together?

 

Dimiter Madjarov
Telerik team
 answered on 22 Feb 2016
2 answers
102 views

Is it possible to make a custom view for the Kendo ui MVC Gantt chart?

I've found documentation on how to do this in JavaScript.
Is this possible? If so is there any documentation or demo instructing on how to do this?

Thanks in advance!

Pavlos
Top achievements
Rank 1
 answered on 22 Feb 2016
20 answers
1.3K+ views
I have a Kendo grid set up for client-side only. Whenever I add a row, then edit it, then cancel - it gets removed. Multiple questions have been asked here about this same issue, and all the suggestions point to incorrect setup of the model's ID.Well, in my case the ID seems to be set up correctly. I am assigning a new ID to the model in the onGridSave() javascript event, like this:

var _curId = 1;
function onGridSave(e) {
    var newId = _curId++;
    e.model.set('id', newId);
    e.model.set('EncryptedIngredientId', newId);
}
And when I look at the data in the grid after having added multiple rows, all of their IDs are unique - from 1 to n.

But when I cancel an edit, in the onGridChange() event the action is "remove", and the cancelled row is removed. This happens for new rows as well as for edited rows, while it should only be the case for new rows.The grid is set up as follows:

@(Html.Kendo().Grid<IngredientViewModel>(Model.ServerData)
 
    .Name("IngredientsGrid")
    .Editable(editable => editable.Mode(GridEditMode.InLine).Enabled(true))
    .BindTo(Model.DataAfterEdit ?? Model.ServerData)
    .DataSource(ds => ds
        .Ajax()
        .ServerOperation(false)
        .Events(ev => ev.Change("onGridChange").Error("onGridError"))
        .Model(m => {
                 m.Id(p => p.EncryptedIngredientId);
                 m.Field(p => p.EncryptedIngredientId).DefaultValue(Guid.NewGuid().ToString());
                 m.Field(p => p.PercentInfo).DefaultValue(new PercentInfoViewModel());
             })
        .Read("IngGrid_Read", "Company") // <-- dummy action that doesn't exist in controller
        .Update("IngGrid_Update", "Company") // <-- dummy action that doesn't exist in controller
        .Create("IngGrid_Create", "Company") // <-- dummy action that doesn't exist in controller
        .Destroy("IngGrid_Destroy", "Company")) // <-- dummy action that doesn't exist in controller
    .ToolBar(tbar => tbar.Create())
    .Columns(c => {
               c.AutoGenerate(false);
               c.Bound(m => m.CasNumber);
               c.Bound(m => m.IngredientName);
               c.Bound(m => m.PercentInfo).ClientTemplate("#= makePercentageDisplayString(data.PercentInfo) #").Width(180);
               c.Bound(m => m.ReachRegNumber);
               c.Bound(m => m.ReachSvhc);
               c.Bound(m => m.RohsSubstance);
               c.Bound(m => m.Prop65Substance);
               c.Command(command => {
                             command.Edit();
                             command.Destroy();
                         }).Width(200);
           })
    .Events(evt => {
                evt.Save("onGridSave");
                evt.Edit("onGridEdit");
            })
)
What am I doing wrong?
Sven
Top achievements
Rank 1
 answered on 22 Feb 2016
1 answer
551 views

Hello,

I have Kendo grid which has Export to PDF button and other Buttons on toolbar. So i am using a toolbar template. As mentioned in Posts to hide toolbar i used the following css to hide toolbar button in exported pdf.

 .k-pdf-export .k-grid-toolbar,
      .k-pdf-export .k-grouping-header {
        display: none;
      }

But my pdf file Shows the toolbar with all Buttons. So i believe must be something to do with template. Please suggest how can i hide toolbar template in export

 

Thanks

 

Anamika

Radoslav
Telerik team
 answered on 22 Feb 2016
1 answer
433 views

In my search to resolve an issue I'm having, I found this post:

 

http://www.telerik.com/forums/select-text-although-allowrowselect-is-true

 

How do we set the EnableDragToSelectRows property to false using the Telerik UI for ASP.NET MVC (powered by Kendo UI) grid?  I have this applied:

 

.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))

 

...and need to disable the marquee select so the users can select and copy text.  Thank you!

-Anthony

Dimiter Madjarov
Telerik team
 answered on 22 Feb 2016
1 answer
156 views

Hey there,

I'm currently using MVC, and have a view model that contains two Enumerables, each one representing a different series for use in the Donut Chart.

Normally, with a single enumerable, I would use the code below to bind the series.  

In my case the view model has two enumerables, Model.Series1 and Model.Series2.  How would I go about modifying this code to accommodate the two series?

@(Html.Kendo().Chart(Model)
    .Name("chart")
    .Title("Single Series")
    .Legend(legend => legend
        .Position(ChartLegendPosition.Bottom)
    )
    .Series(series =>
    {
        series.Donut(
            model => model.Value,  // The data to use
            model => model.Category, // The category Name
            model => model.Color, // The color to use for the category
            null // How far out the donut section should pop out
        );
 
    })
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Template("#= category # - #= kendo.format('{0:P}', percentage) #")
    )
)

Iliana Dyankova
Telerik team
 answered on 19 Feb 2016
6 answers
623 views

Hi,

     I tried to intercept "Edit" ClientEvent and argument properties are all undefined.  

 Here is the function and alerts are displayed, so I know the event is called.  What did I miss?

 

Thank you

        function onEdit(e)
        {
            alert(e.dataItem);
            alert(e.mode);
            alert(e.form);
            alert(e.isNew);
            if (e.mode == "edit" && (typeof e.dataItem != 'undefined') && (e.dataItem != null)) {
                alert('a');
                $(e.form).find('#Description').hide();
            }

        }

Slav
Telerik team
 answered on 19 Feb 2016
4 answers
155 views

I've noticed then in new version (2016.1.112) of component KendoDropDownList was changed the logic of the change event. In previous version (2015. 3.1111) in the change function I don't have to return the proper value. Below is the razor code that works fine.

...................
                <tr>
                    <td class="required-label">
                        @Html.LabelFor(m => m.FolderId)
                    </td>
                    <td>
                        @(Html.Kendo().DropDownList().Name("FolderId")
                              .HtmlAttributes(new { @class = "select-list" })
                              .OptionLabel("-- WYBIERZ RODZAJ ZGŁOSZENIA --")
                              .DataTextField("Description")
                              .DataValueField("Symbol")
                              .DataSource(source => source.Read(read => read.Action("GetFolders", "Zgloszenia"))))
                    </td>
                </tr>
                <tr>
                    <td class="required-label">
                        @Html.LabelFor(m => m.Subject)
                    </td>
                    <td>
                        @Html.Kendo().TextBoxFor(m => m.Subject).HtmlAttributes(new { @class = "textboxlong" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(m => m.ForeignCode)
                    </td>
                    <td>
                        @Html.Kendo().TextBoxFor(m => m.ForeignCode)
                    </td>
                </tr>
                <tr>
                    <td class="required-label">
                        @Html.LabelFor(m => m.ProductId)
                    </td>
                    <td>
                        @(Html.Kendo().DropDownList().Name("ProductId")
                              .HtmlAttributes(new { @class = "select-list", data_val = "true", data_val_required = "Musisz wybrać odpowiedni program z listy" })
                              .OptionLabel("-- Wybierz produkt, którego dotyczy zgłoszenie --")
                              .DataTextField("DescriptionValid")
                              .DataValueField("Symbol")
                              .DataSource(source => source.Read(read => read.Action("GetProducts", "Zgloszenia").Data("filterProducts"))
                                  .ServerFiltering(true))
                              .Enable(false)
                              .AutoBind(true)
                              .CascadeFrom("FolderId")
                              )
                    </td>
                </tr>
..................
<script>
    $(function () {
        var folderObj = $("#FolderId");
        if (folderObj) {
            folderObj.data("kendoDropDownList").setOptions({
                change: function (e) {
                    var folderVal = folderObj.val();
                    if (folderVal == "ZSER") {
                        $("#versionLabel").removeClass("required-label");
                        $("#Version").removeAttr("data-val-required");
                    } else {
                        $("#versionLabel").addClass("required-label");
                        $("#Version").attr("data-val-required", "Podanie wersji programu jest wymagane");
                    }
                }
           });
        }
    });
</script>
 

 In the new version it turned out that my dropdownlist doesn't work, operator cannot choose the item. Exactly after clicking on, it drop down, but after choosing the item it still remains the previous one. It looks like someone has disabled the control. I've found that if add to my function return value, everything will be OK.  My question is if this logic will be developed in the future? Should I always remember to return the proper value? Below is new version of this function.

<script>
    $(function () {
        var folderObj = $("#FolderId");
        if (folderObj) {
            folderObj.data("kendoDropDownList").setOptions({
                change: function (e) {
                    var folderVal = folderObj.val();
                    if (folderVal == "ZSER") {
                        $("#versionLabel").removeClass("required-label");
                        $("#Version").removeAttr("data-val-required");
                    } else {
                        $("#versionLabel").addClass("required-label");
                        $("#Version").attr("data-val-required", "Podanie wersji programu jest wymagane");
                    }
                }
                return folderVal;
            });
        }
    });
</script>

Janusz
Top achievements
Rank 1
 answered on 19 Feb 2016
1 answer
237 views

I'm having to dynamically create instances of the kenod dropdownlist and I have it working fine except I need to know what the equivalent syntax for defining the datasource.

 

Here is the razor server-side syntax:

 

@(Html.Kendo().DropDownList()
                        .Name("lineItemTypeCode")
                        .OptionLabel("..........")
                        .HtmlAttributes(new { style = "width:100%", @class = "itemTypeClass", required = "required" })
                        .DataValueField("Code")
                        .DataTextField("Name")
                        .DataSource(source => { source.Read(read => { read.Action("GetItemTypes", "RequestPONumber").Data("GetSelectedLocation"); }); })
      )

Action is GetItemTypes

Controller is RequestPONumber

Here is my client-side:

var newItemTypeDdl = $("#itemTypeddl" + poLinesCount).kendoDropDownList(
            {
                dataTextField: 'Name',
                dataValueField: 'Code',
                dataSource: ??????,
                optionLabel: "..........",
            });

 

Georgi Krustev
Telerik team
 answered on 19 Feb 2016
1 answer
107 views

Hello everyone.

Setup

I am using Telerik MVC Datepicker control to allow the user to select a date.

My date range is between the beginning of 1997 to current day.

The list of Valid dates are in a database and can be called via Stored Procedure.

My current list of valid dates number about 3500 and most represent end of month dates (though not always).

I want to disable all the other dates in my date picker so that the user only has access to dates that have data associated with them.

Is there a way to use the DisableDates feature of the Datepicker to do this?

 

Thanks

Corey

Kiril Nikolov
Telerik team
 answered on 19 Feb 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
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
DateTimePicker
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?