Telerik Forums
UI for ASP.NET MVC Forum
1 answer
1.1K+ views

I'm having an issue getting the selected item from the passed event, mostly because the demo uses "e.dataitem"

like this:

function onSelect(e) {
        if ("kendoConsole" in window) {
            var dataItem = e.dataItem;
            kendoConsole.log("event :: select (" + dataItem.Text + " : " + dataItem.Value + ")");
        }
    }
My attempt to recreate this failed, dataItem has no such members:


@(Html.Kendo().MultiSelect()
                              .Name("JobIds")
                              .HtmlAttributes(new { style = "Width:700px; height:60px; overflow-y:scroll;", aria_label = "editor" })
                              .DataTextField("job_name")
                              .DataValueField("job_id")
                              .HeaderTemplate("<div class=\"dropdown-header\">" +
                                        "<span style=\"width=350px\">Job Name</span>" +
                                        "<span style=\"width=350px\">Parent Name</span>" +
                                        "</div>\n <table>")
                              .ItemTemplate("<span class = \"namespan\">#: data.job_name #</span> <span class=\"parentspan\">#: data.job_parent #</span >")
                              .DataSource(source =>
                                {
                                    source.Read(read =>
                                    {
                                        read.Action("JobSearch", "SupportEditor");
                                    })
                                    .ServerFiltering(true);
                                })
                              .Events(e =>
                              {
                                  e.Select("Job_onSelect")
                                  })


function Job_onSelect (e) {
        var dataItem = e.dataItem;
        console.log("event :: select (" + dataItem.Text + " : " + dataItem.Value + ")");
    }


The console reads:


event :: select (undefined : undefined)


The only way i have managed to pull data is with direct reference to the multiselect like below:

function Job_onSelect(e) {
console.log($("#JobIds").data("kendoMultiSelect").value().toString());
}
But this does not provide the values of selected item value as it is selected; instead it only gives the full value of the multiselect before the change occurs (e.g. if 3 items are selected it only returns items 1 and 2, and when the first item is selected it returns nothing).
Petar
Telerik team
 answered on 25 Jan 2022
1 answer
381 views

Hi there! In the code below when i reach $("#bans-grid").kendoGrid() function i get the type of error i've mentioned in the title. I don't understand why. Any help will be appreciated!


 $("#saveButton").kendoButton({
              click: function() {

                  var channelsData = $("#bans-grid").data().kendoGrid.dataSource.view();
                  var channelsDataJson = JSON.stringify(channelsData);

                      $("#bans-grid").kendoGrid({
                          dataSource: {
                                 transport: {
                                     update: {
                                         data: channelsDataJson,
                                         url: "/bg/NotosPrime/Bans/BanChannels",
                                         type: "PUT"
                                       }
                                     },
                                     schema: {
                                         model: {
                                             id: "Id"
                                         }
                                     }
                                }
                             });
                             $("#bans-grid").dataSource.sync();
                }
            });

Petar
Telerik team
 answered on 25 Jan 2022
8 answers
1.1K+ views
Hi,

I've been trying to set a grid in popup edit mode, with an upload in a custom editor template, but can't get this to work, the  doesn't have a value. Here's my editor template and controller, the view only have a grid set with ajax CRUD operations and popup edit mode. If this possible (a sync upload in editor template), or I need to set async save for the upload?

Controller:

public JsonResult InsertWithImage([DataSourceRequest]DataSourceRequest request, HttpPostedFileBase Picture)
        {
            var item = repository.CreateNew();
            try
            {
                UpdateModel(item);
                if (Picture != null)
                {
                    Picture.InputStream.Read(item.Image, 0, (int) Picture.InputStream.Length);
                    item.Image_Ext = Picture.ContentType;
                }
                repository.Add(item);
                unitOfWork.SaveChanges();
            }
            catch (Exception err)
            {
                ...
            }
            return
                Json((new[] { item }.ToDataSourceResult(request, ModelState)));
        }


EditorTemplate:

<fieldset>
    ...
    <div class="row">
            @Html.LabelFor(model => model.Image)<br />
            @(Html.Kendo().Upload().Name("Picture").Multiple(false)
                .HtmlAttributes(new Dictionary<stringobject>{
                                                                  {
                                                                      "style""width: 100%"
                                                                  }}))
            @Html.ValidationMessageFor(model => model.Image)
        </div>
</fieldset>

Eduardo
Tony
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 24 Jan 2022
1 answer
197 views

When activating the editable.mode in a checkbox it makes the UI control non clickable.


Details: When the mouse hover the checkbox it activates the editable mode on the checkbox but right after that when I try to click it the UI does not response.


Kendo UI version: '2016.1.112'

 

Anton Mironov
Telerik team
 answered on 20 Jan 2022
0 answers
163 views

Hello,

I'm having a strange problem with a cascading dropdown. I have an in cell edit grid for a list in my model. I have two dropdowns in editor templates. CustomerContact cascades from Customer. Both dropdowns are bound to a SelectListItem object on my model with properties "Text" and "Value". Both dropdowns function normally on initial selection and the value of both dropdowns is successfully set as an object. I'm able to use #= data.Text # in a ClientTemplate to display the text of the selected item.

This is where it gets weird. If I click to focus the cell containing my cascaded CustomerContact dropdown, and then click off without actually expanding the dropdown, the value changes from being the whole object to just the DataValueField ("Value" in my case). I've checked and sure enough the datasource change event is triggered when i click off of the cell for the CustomerContact dropdown even though I haven't opened it. This doesn't happen to the Customer dropdown, so it must be something with the cascade but I really can't understand what is causing it. Code below and some screenshots of before and after click my second dropdown's cell. Any help would be appreciated!

Grid:

@(Html.Kendo().Grid(Model.ScheduledInteractions)
     .Name("scheduled-interactions-grid")
     .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model =>
           {
                    model.Id(p => p.Id);
                    model.Field(p => p.Customer).DefaultValue(new SelectListItem() { Text = "- Select -", Value = "-1" });
                    model.Field(p => p.CustomerContact).DefaultValue(new SelectListItem() { Text = "- Select -", Value = "-1" });
             })
            .ServerOperation(false))
            .Columns(c =>
            {
                c.Command(cmd => cmd.Destroy()).Width(100);
                c.Bound(x => x.Customer).EditorTemplateName("CustomerDropdown")
                    .ClientTemplate("#= data.Customer ? data.Customer.Text : '' #" +
                    "<input type='hidden' name='ScheduledInteractions[#= getIndex(data)#].Customer' value='#= data.Customer #' />"
                );
                c.Bound(x => x.CustomerContact).EditorTemplateName("CustomerContactDropdown")
                .ClientTemplate("#= data.CustomerContact ? data.CustomerContact.Text : '' #" +
                    "<input type='hidden' name='ScheduledInteractions[#= getIndex(data)#].CustomerContact' value='#= data.CustomerContact #' />"
                );
                c.Bound(x => x.InteractionType).EditorTemplateName("InteractionTypeDropdown")
                .ClientTemplate("#= InteractionType #" +
                    "<input type='hidden' name='ScheduledInteractions[#= getIndex(data)#].InteractionType' value='#= InteractionType #' />"
                );
                c.Bound(x => x.Description).ClientTemplate("#= Description #" +
                    "<input type='hidden' name='ScheduledInteractions[#= getIndex(data)#].Description' value='#= Description #' />"
                );
            })
            .ToolBar(tb => {
                tb.Create();
            })
            .Navigatable()
            .Editable(editable => editable.Mode(GridEditMode.InCell))
        )

Editor Templates:

@model SelectListItem
    @(Html.Kendo().DropDownListFor(m => m)
        .Name("customer-select")
        .HtmlAttributes(new { @class = "form-control", name = Html.NameFor(m => m) })
        .OptionLabel("- Select -")
        .DataTextField("Text")
        .DataValueField("Value")
        .Filter("contains")
        .DataSource(ds =>
        { 
            ds.Read(read =>
            {
                read.Action("CompanyOptions", "Common", new { Area = "API" }).Data("filterCustomersInGrid");
            }).ServerFiltering(true);
        })
    )
    @Html.ValidationMessageFor(m => m, "", new { @class = "text-danger" })
@model SelectListItem
    @(Html.Kendo().DropDownListFor(m => m)
        .Name("customer-contact-select")
        .HtmlAttributes(new { @class = "form-control", name = Html.NameFor(m => m) })
        .OptionLabel("- Select -")
        .DataTextField("Text")
        .DataValueField("Value")
        .Filter("contains")
        .DataSource(ds => 
        { 
            ds.Read(read => 
            {
                read.Action("ContactOptions", "Common", new { Area = "API" }).Data("filterContactsInGrid");
            }).ServerFiltering(true);
        })
        .AutoBind(false)
        .CascadeFrom("customer-select")
    )
@Html.ValidationMessageFor(m => m, "", new { @class = "text-danger" })

Javascript:

function getCurrentGridRow() {
    var grid = $("#scheduled-interactions-grid").data("kendoGrid");
    var editRow = grid.tbody.find("tr:has(.k-edit-cell)");
    return grid.dataItem(editRow);
}

function filterCustomersInGrid() {
    var row = getCurrentGridRow();
    return { contains: '', currentId: row.Customer ? row.Customer.Value : null };
}

function filterContactsInGrid() {
    var row = getCurrentGridRow();
    return { companyId: row.Customer ? row.Customer.Value : null, contains: '', currentId: row.CustomerContact ? row.CustomerContact.Value : null };
}

function getIndex(dataItem) {
    var data = $("#scheduled-interactions-grid").data("kendoGrid").dataSource.data();
    return data.indexOf(dataItem);
}

Value of Dropdowns After Initial Selections

After Cell Click:


Sarah
Top achievements
Rank 1
 updated question on 19 Jan 2022
0 answers
308 views

Hi guys,

we been using Kendo version 2020.1.406.545. is it a must to upgrade to the latest?

kind regards

Tony

Tony
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 19 Jan 2022
1 answer
415 views

I am attempting to keep the Gantt Chart editable, but remove the ability to create new tasks/child entries.

 

I have tried adding this CSS and it did not work:

  .k-gantt-actions .k-button {
            visibility: hidden;
        }

The button still shows.

 

Any help?

Yanislav
Telerik team
 answered on 19 Jan 2022
1 answer
173 views
In the grid control I want to do GridFilterMode.Row filtering but to increase performance I want to remove the auto complete and default filtering.  How can I disable that option and just make it a manual filter only?
Eyup
Telerik team
 answered on 19 Jan 2022
1 answer
389 views

We've added the Telerik.UI.for.AspNet.Mvc4.2021.3.1207 NuGet package to our project and I was wondering what the best practices are for excluding unneeded content from publishing. There is a folder called 2021.3.1207-source which by default is published with all the other content that the NuGet package has added. So far we have manually marked the content to not be included when published in our build pipelines, but we're wondering if there is a more standard way of doing this? Is there a NuGet package which excludes the source folder?

In addition to this, is there a preferred method of excluding themes from a project? Again we can manually remove them or mark them to not be published, but I was wondering if there is a suggested way to configure what is and isn't included.

Many thanks

Ivan Danchev
Telerik team
 answered on 19 Jan 2022
1 answer
159 views
I'm using a kendo UI grid for MVC and I've managed to create a dropdown for a field in the grid using an editor template.  The only problem is that the drop-down does not default to the value that is currently in the field. Can someone explain how to do this or point me to a demo? Thanks.
Eyup
Telerik team
 answered on 18 Jan 2022
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
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
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
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?