Telerik Forums
UI for ASP.NET MVC Forum
6 answers
2.0K+ views
Not exactly sure the best way to code the following scenario...I have Upload, ComboBox and Grid controls. The Grid has a column with a Dropdown/Select column. The data for this columns needs to be populated based upon the selected value of the ComboBox. The Grid itself is not populated until after the Upload control has performed its actions. The data (re)bound to the Grid also has the same value from the ComboBox.

I've tried two types of columns for the Grid. A Foreign Key column and a Bound column with an EditorTemplate. Both will retrieve an initial dataset of all records, but neither can I figure out how to filter or rebind based upon the new data (available after the Upload control is complete).

I'm working in MVC. I've looked at this doc http://docs.kendoui.com/api/wrappers/aspnet-mvc/Kendo.Mvc.UI.Fluent/GridBoundColumnBuilder#editorviewdatasystemobject but it does not allow me to pass data from the Model to the EditorTemplate as documented. I also was unable to find the documentation on how to use the EditorView object in the EditorTemplate.

ComboBox:
@(Html.Kendo().ComboBox()
    .Name("engineGroupList")
    .Placeholder("Select Engine Group...")
    .DataTextField("EngineGroupName")
    .DataValueField("EngineGroupId")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetEngineGroups", "Equipment")
                .Data("engineGroupFilter");
        });
    })
    .CascadeFrom("customerList")
    .Events(events => events.Change("engineGroupChange"))
)
Upload:
@(Html.Kendo().Upload()
    .Name("dasFiles")
    .Async(a => a
        .Save("UploadDas", "Data")
        .AutoUpload(true)
        .Batch(true)
    ).Events(events => events.Success("dasFilesSuccess")
)
Upload (Event Script):
function dasFilesSuccess(e) {
    var grid = $("#dasFilesGrid").data("kendoGrid");
    grid.dataSource.data(e.response.Data);
}
Grid - 2nd column needs to be a dropdown bound based on one of two possible parameter: FileUploadGroupId (in Grid data model) or EngineGroupId (value of ComboBox):
@(Html.Kendo().Grid(Model)
    .Name("dasFilesGrid")
    .Columns(columns =>
    {
        columns.Bound(m => m.FileUploadRawFileName);
        columns.Bound(m => m.FileUploadGroupId).EditorTemplateName("Engine");
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(e => e.FileUploadRawId);
        })
    )
)
EditorTemplate - Currently Binding to All EngineModels, but need to call either by EngineModel.GetByEngineGroupId(...) or GetByUploadGroupId(...):
@model List<EngineModel>
 
@(Html.Kendo().DropDownListFor(m => m)
        .Name("Engine")
        .DataValueField("EngineID")
        .DataTextField("Model")
        .BindTo((System.Collections.IEnumerable)EngineModel.All())
)
Ideas?
Viktor Tachev
Telerik team
 answered on 03 Sep 2019
24 answers
737 views

Hi

 

I saw a thread about not getting to the ID of a panelbar item in the OnSelect handler from 2012. I almost can't believe that Telerik did not yet fix this issue. But i can't find anything so i'm afraid they didn't. 

It should be that easy to add to the component.

 

Eric

 

Ivan Danchev
Telerik team
 answered on 30 Aug 2019
1 answer
133 views

I have a partial view that contains a TabStrip and each that contains a grid. The view works, it's currently in a different page and I'd like to move it to a kendo window.

I've moved it to a kendo window and the window displays great.

Here's the code that generates my window (please note the variable names have been changed for this).

var window = $("#window").kendoWindow({
                content: {
                    url: "/Case/CaseDetail",
                    data: {
                        Daid: Daid,
                        CaseID: CaseID,
                        RecordID: RecordID,
                        CanUserView: cuv,
                        OffenseCount: OffenseCount,
                        CoDefendantCount: CoDefendantCount,
                        VWCount: VWCount,
                        InternalProcessCount: InternalProcessCount,
                        ChargeDispositionCount: ChargeDispositionCount,
                        SentenceCount: SentenceCount,
                        OtherCaseCount: OtherCaseCount
                    }
                },
                actions: [
                    "Pin",
                    "Minimize",
                    "Maximize",
                    "Close"
                ],
//                close: onClose
            });
 
            window.kendoWindow().data("kendoWindow").center().open()

 

The window appears and the tabs are visible, the content of the 1st tab is loaded via an AJAX call that is never executed (so no content) and none of the tabs are functional when I click on it.

When I look at the page source I can see that the window was rendered as text and all associated javascript is actual text and not, all the scripts related seem to be escaped, here's an example of some rendered content:

<script type="text/javascript">
    function ProcessErrorO(args) {
        ProcessError(args, 'O_grid_' + '#= RecordID #');
    }
<\/script>

 

Any help would be appreciated.

Thanks

Martin
Telerik team
 answered on 29 Aug 2019
1 answer
563 views

I had a subcription 5 years ago and have decided to renew my subscription to get the latest version of Kendo for MVC. Our code uses bootstrap as well as Kendo, with JQuery. I was expecting to be able to upgrade all of these to their latest versions. However, I notice that the JQuery file used by Kendo is still 1.12.4, but Visual Studio is referenceing 3.4.1 by default. 

Is it possible to ditch 1.12.4 and kendo work with 3.4.1?

 

Nikolay
Telerik team
 answered on 29 Aug 2019
2 answers
162 views

Hello everyone,

It's possible to apply a filter on one field automatically?  When I load the page I want one filter applied without the user have to do it each time.  Of course he can remove it.

 

See attachment.

 

Louis
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 28 Aug 2019
3 answers
653 views

Hello, with my code below I want to populate the dropdown and the grid(with all rows), then if the user makes a selection in the dropdown I want the grid to be refreshed with the filtered rows. The NewPartsRead controller action does return the filtered rows, but the grid does not rebind to the filtered rows returned.

What am I doing wrong?

Index:

 @using (Html.BeginForm())
                {    <div class="demo-section k-content" style="padding:20px;">
                     
                        @(Html.Kendo().DropDownList()
                                                    .Name("EngMake")
                                                    .DataTextField("Text")
                                                    .DataValueField("Value")
                                                    .BindTo(Model.EngMakeList)
                                                    .SelectedIndex(0)
                                                    .OptionLabel("Select Engine Manufacturer")
                                                    .HtmlAttributes(new { style = "width:300px" })
                                                    .Filter(FilterType.Contains)
                        )

 

 

                    </div>

                         @(Html.Kendo().Grid(Model.NewParts)
                                           .Name("grid")
                                           .Columns(columns =>
                                           {
                                               columns.Bound(p => p.EngDescription);
                                               columns.Bound(p => p.PartType);
                                               columns.Bound(p => p.EngYear);
                                               columns.Bound(p => p.EngCylinders);
                                               columns.Bound(p => p.EngBore);
                                               columns.Bound(p => p.PartYears);
                                               columns.Bound(p => p.Partieb);
                                               columns.Bound(p => p.PartNotes);
                                           })
                                           .Pageable()
                                           .Sortable()
                                           .Scrollable()
                                           .Filterable()
                                           .HtmlAttributes(new { style = "height:550px;" })
                                           .DataSource(dataSource => dataSource
                                               .Ajax()
                                               .PageSize(20)
                                               .Read(read => read.Action("Index", "NewPartsRead"))
                                            )
                    )
                }

 

Controller:

  public class NewPartsController : Controller
    {
        // GET: NewParts
        public ActionResult Index()
        {
            var model = new NewPartsModel();
            return View(model);
        }
        [HttpPost]
        public ActionResult NewPartsRead(NewPartsModel newPartsModel)
        {
            newPartsModel.NewParts = newPartsModel.NewPartsRead(newPartsModel.EngMake);

            return Json(newPartsModel.NewParts);
        }
    }

 

Model:

 protected readonly NewPartsProvider newPartsProvider = new NewPartsProvider();

        public string EngMake { get; set; }

        public List<DataObjects.NewPart> NewParts { get; set; }

        public List<SelectListItem> engMakeList = new List<SelectListItem>();

        public IEnumerable<SelectListItem> EngMakeList { get; set; }

        public NewPartsModel()
        {
            foreach (var engMake in newPartsProvider.GetEngMakeList())
                engMakeList.Add(new SelectListItem() { Text = engMake, Value = engMake });

            EngMakeList = engMakeList;
            NewParts = newPartsProvider.GetNewParts();
        }

        public List<DataObjects.NewPart> NewPartsRead(string engMake)
        {
            List<DataObjects.NewPart> NewParts = new List<DataObjects.NewPart>();

            NewParts = newPartsProvider.GetNewPartsByMake(engMake);

            return NewParts;
        }

 

n/a
Top achievements
Rank 1
 answered on 27 Aug 2019
1 answer
113 views

Hello,

@(Html.Kendo().Grid<Myproject.Areas.Maintenance.ViewModels.EquipementsInterventions.EquipementInterventionModel>()
            .Name("EquipementIntervention")
            .Columns(columns =>
            {
                columns.Bound(p => p.NoReference).Width(60);
                columns.Bound(p => p.DateIntervention).Format("{0:yyyy-MM-dd}").Width(60).HtmlAttributes(new { style = "text-align:center" });
            })
            .ToolBar(toolBar =>
            {
                toolBar.Create();
                toolBar.Save();
            })
            .Editable(editable => editable.Mode(GridEditMode.InCell))
            .HtmlAttributes(new { style = "font-size:11px;height: 300px;" })
            .Scrollable()
            .Selectable(s => s.Enabled(false))
            .Pageable(pageable => pageable
            .Refresh(true)
            .ButtonCount(5))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Batch(true)
                .ServerOperation(false)
                .PageSize(100)
                .Model(model =>
                {
                    model.Id(field => field.NoEquipementIntervention);
                    model.Field(field => field.NoReference).DefaultValue("Test");
                    model.Field(field => field.DateIntervention).DefaultValue(System.DateTime.Now);
                })
                .Read(read => read.Action("Read", "Equipements", new { id = Model.EquipementId }))
                .Create(create => create.Action("Create", "Equipements", new { id = Model.EquipementId }))
                .Update(update => update.Action("Update", "Equipements"))
                .Destroy(destroy => destroy.Action("Destroy", "Equipements"))
            )
)

I try to set a default value when I add a new item in my grid.  Even with a hard coded value like "Test".  I have the same situation with a DateTime? field until I remove the ?.  Any idea about the NoReference (string) field?

The model :

[Key]
public Guid NoId { get; set; }
 
[Required]
 
public string NoReference { get; set; }
 
[UIHint("Date")]
[Required]
public DateTime DateIntervention { get; set; }

 

The Grid :

 

 

THANK A LOT TO EVERYONE.

 

 

 

Viktor Tachev
Telerik team
 answered on 27 Aug 2019
1 answer
440 views

Hello, I was wondering if it was possible to to the use DateRangePicker for selecting a range of months instead of days. I currently have the following code:

@(Html.Kendo().DateRangePicker()
                                  .Name("MonthlyDatePicker")
                                  .HtmlAttributes(new { style = "width: 100%" })
                                  .Events(e => e.Change("onMonthlyChange"))
                                  .Start("year")
                                  .Depth("year")
                                  .Format("MM yyyy")
                                )

 

This code appears the way I want it to but does not allow the user to select a month. Any help is much appreciated. Thanks

 

Viktor Tachev
Telerik team
 answered on 27 Aug 2019
1 answer
1.0K+ views

Hi,

How do we set the series colours on an AJAX MVC Bar chart.

there is an option to set the colors but doesnt seem to matter what is entered nothing works

@(Html.Kendo().Chart<CML.Models.TopRequestersSample_Result>()
    .Name("TopRequesters")
    .SeriesColors()
    .Title("Top 10 Requesters by Sample Count")
    .Legend(legend => legend.Position(ChartLegendPosition.Bottom))
    .DataSource(ds => ds.Read(read => read.Action( "GetTopRequesters","Dash" ) ))
    .Series( s => { s.Bar( a => a.Total ); } )
    .CategoryAxis(ca => {
        ca
   .Categories( a => a.DisplayName )
   .Name( "Requester" );
    })

 

Nikolay
Telerik team
 answered on 23 Aug 2019
3 answers
360 views

I used the solution (slightly modified for my use case) referenced in the docs to add a new row when tabbing out of the last editable column in the last row. However, when the new row is added, the changes made to that last editable cell are lost. How do I prevent that from happening?

Here's my code. The "return false;" was necessary to prevent the focus going to the second column of the new row. The undesired behavior is occurring whether or not I include it.

$(document).ready(function () {
    var grid = $("#ReceivingReportGrid").data("kendoGrid");
 
    grid.tbody.on("keydown", function (e) {
        if (e.keyCode == 9) {
            if ($(e.target).closest('td').is(':nth-last-child(2)') && $(e.target).closest('tr').is(':last-child')) {
                grid.addRow();
                return false;
            }
        }
    });
});
Georgi
Telerik team
 answered on 23 Aug 2019
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
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
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?