Telerik Forums
UI for ASP.NET MVC Forum
2 answers
226 views

Hi All,

Struggling with a very peculiar problem.

I have a Kendo grid with kendo dropdownlist in some of the columns. The dropdown is populated based on values from in the database.

Problem:

On Edit in grid, the dropdown is not preserving previous saved value. 

Please can you help me in finding  the solution for the problem.

VIEW Code:

 @(Html.Kendo().Grid<ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel>(Model)
    .Name("gridTable")    
    .HtmlAttributes(new { style = "font-family: verdana,arial,sans-serif; font-size: 11px;color: #333333;border-color: #999999;" })
    .Columns(columns =>
    {
        columns.Bound(p => p.ClientAppName).ClientTemplate("# try {# #=ClientAppName# #} catch (e) {}#").EditorTemplateName("ClientComboBoxLookup").Width(120).Filterable(ft => ft.UI("ClientApplicationsFilter"));
      
        columns.Bound(p => p.SupplierAppName).ClientTemplate("# try {# #=SupplierAppName# #} catch (e) {}#").EditorTemplateName("SupplierComboBoxLookup").Width(120).Filterable(ft => ft.UI("SupplierApplicationsFilter"));
      
        columns.Bound(p => p.ListName).ClientTemplate("# try {# #=ListName# #} catch (e) {}#").EditorTemplateName("MasterDataListsComboBoxLookup").Width(150).Filterable(ft => ft.UI("ListsFilter"));
        columns.Bound(p => p.ClientValueName).Width(120).Title("Client Value");
        columns.Bound(p => p.ClientValueDescription).Width(200);
        columns.Bound(p => p.ClientCodingSystem).Width(150);
        columns.Bound(p => p.SupplierValueName).Width(120).Title("Supplier Value"); ;
        columns.Bound(p => p.SupplierValueDescription).Width(200);
        columns.Bound(p => p.SupplierCodingSystem).Width(150);
        columns.Bound(p => p.Direction).Width(90).ClientTemplate("# try {# #=Direction# #} catch (e) {}#").EditorTemplateName("DirectionComboBoxLookup").Filterable(ft => ft.UI("DirectionsFilter"));
        columns.Command(command =>  {
                command.Edit();
                command.Destroy();
            }).Width(200);
       
    })
            .ToolBar(t => t.Create())
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Filterable(e => e.Extra(false))
            .Pageable(page => page.PageSizes(new int[] { 10, 25, 50, 100 }).Enabled(true))
            .Sortable()
            .Scrollable(src => src.Height("auto"))
            .Resizable(resize => resize.Columns(true))
            .DataSource(
                source => source
                    .Ajax() 
                    .Events(events => events.Error("error_handler"))                    
                    .ServerOperation(true)                  
                    .Model(model =>
                {
                    model.Id(e => e.MasterDataMappingId);
                    model.Field(e => e.MasterDataMappingId).Editable(false);
                    //model.Field(p => p.ClientAppName).Editable(true).DefaultValue(ViewData["defaultApplications"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                    //model.Field(p => p.SupplierAppName).Editable(true).DefaultValue(ViewData["defaultApplications"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                    //model.Field(p => p.ListName).Editable(true).DefaultValue(ViewData["defaultMasterDataList"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                    
                })                
                .Create(create => create.Action("Create_MasterDataMapping", "Home"))
                .Read(read => read.Action("Read_MasterDataMapping", "Home"))
                 .Update(update => update.Action("Update_MasterDataMapping", "Home"))
                 .Destroy(destroy => destroy.Action("Destroy_MasterDataMapping", "Home")))
                 //.Events(e => e.Edit("onEdit"))
            )

 Editor Template:

@(Html.Kendo().DropDownListFor(m => m)
        .Name("ClientAppName")
        .DataValueField("AppId")
        .DataTextField("ApplicationName")
        .BindTo((System.Collections.IEnumerable)ViewData["Applications"])
        .AutoBind(false)        
        .Events(e =>
        {
            e.Select("onSelect");
        })
)

Daniel
Telerik team
 answered on 16 Jun 2015
6 answers
264 views

Hi

 version 2015.1.515

 I try use dropdownlist with virtual in kendo grid, edit mode - InCellEdit. Works fine for select new value, but if i open cell for edit, dropdown show default value (option label). Autobind is set to false.

 

With version 2015.1.515 and Autobind = false, works with litle hack. (on grid Edit event after 500ms i call dropdown.datasource.read()).

function OnGridEdit()
 
{
 
  setTimeout(function() {
                var artDrop = $("#ArticleId").data("kendoDropDownList");
                if(artDrop)
                {
                    artDrop.dataSource.read();
                }
            }, 300);
 
 }
 

 

But with version 2015.1.515 not work anymore, still reset value to default. I found another hack how this work, but i'm not happy with it. On edit event after some ms set value to dropdown from grid model.

 Is another way to use dropdownlist with virtual in grid with incell edit? Thanks

01.function OnGridEdit(e)
02.{
03.  
04.  setTimeout(function() {
05.                var artDrop = $("#ArticleId").data("kendoDropDownList");
06.                if(artDrop)
07.                {
08.                    artDrop.value(e.model.ArticleId);
09.                }
10.            }, 300);
11.  
12. }
13.  
14.
 

 Editor template for grid

01.<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<int?>"  %>
02.     
03.<script type="text/javascript">
04.    function ArticlesReadPostData() {
05.        return {
06.            __RequestVerificationToken: $('[name=__RequestVerificationToken]').val(),
07.            onlyNotStorable: false,
08.            excludeRound: true
09.        }
10.    }
11.</script>
12. 
13.   <%=
14.    Html.Kendo().DropDownList()
15.        .HtmlAttributes(new { style="width:100%;" })
16.        .ValuePrimitive(true)
17.        .MinLength(1)
18.        .Name("ArticleId")         // Name of the widget
19.        .DataTextField("ArticleCode")
20.        .DataValueField("ArticleId")
21.        .OptionLabel(new { ArticleId = "", ArticleCode = LanguageResources.Resource.L_ChooseFromOptions })
22.        .Filter(FilterType.StartsWith)
23.        .AutoBind(false)
24.         .DataSource(source =>
25.        {
26.            source.Custom()
27.                .ServerFiltering(true)
28.                .ServerSorting(true)
29.                .Sort(srt => srt.Add("ArticleCode"))
30.                .ServerPaging(true)
31.                .PageSize(31)
32.                    .Type("aspnetmvc-ajax") //Set this type if you want to use DataSourceRequest and ToDataSourceResult instances
33.                    .Transport(transport =>
34.                    {
35.                         
36.                        transport.Read(rd =>
37.                        {
38.                            rd.Data("ArticlesReadPostData");
39.                            rd.Type(HttpVerbs.Post);
40.                            rd.Action("ReadArticlesFilteredCombobox", "Article");
41.                        });
42.                    })
43.                    .Schema(schema =>
44.                    {
45.                        schema.Data("Data") //define the [data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data) option
46.                            .Total("Total"); //define the [total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total) option
47. 
48.                    });
49.        })
50.        .Virtual(v => v.ValueMapper("function(e) { return ArticleValueMapper.call(this, e, ArticlesReadPostData()) }"))
51. 
52.     
53. %>

Georgi Krustev
Telerik team
 answered on 16 Jun 2015
3 answers
154 views

Hello,

 I have a context menu on a appointment with a right click, together with a changed event on a selectable scheduler to track the selected item, which I need in the contextmenu. The problem is when I have a context menu open and I do a right-click on another appointment the change event for the scheduler doesn't fire. This leads to actions on the wrong event because the selected item is not updated.

How can I solve this?

events.Change("onSelectionChanged");

 function onSelectionChanged(e) {
   currentEvent = e.events[0];

..

 

JKattestaart
Top achievements
Rank 1
 answered on 16 Jun 2015
1 answer
1.0K+ views
Hi, is it possible to name the worksheet when exporting a grid to Excel?  Please provided details if so (preferably with server widget syntax).
Plamen Lazarov
Telerik team
 answered on 16 Jun 2015
1 answer
92 views

Hi guys,

So, I'm developing a timesheets functionality for our product.

For the week view I have a grid and a model bound to it with some ids for project/client/item/etc. and each of the seven days of the week as decimals.

This works great when entering the time as decimal values, eg: 2.5 or 1.15. I use a clientTemplate to format it and display it as 02:30 or 1:09.

So far so good. Now comes the requirement that we want to be able to also input time as 2:30 or 1:09. The problem is the input box does not allow me to input the ":" sign. My workaround was to use string instead of decimal in the model for days. Got that to work nicely but now the sum aggreggates don't work anymore.

Since I know we cannot have custom aggreggates my question is: how can I sort this issue? I would prefer to have the model as decimal and a way to also input time as 00:00 since I can split them apart and make a decimal out of it to fit the model.

Thank you for your time.

 

Kind regards,

Mircea D.

Rosen
Telerik team
 answered on 16 Jun 2015
2 answers
155 views

I use this to validate required fields on post

        var validator = $("#caseForm").kendoValidator().data("kendoValidator");
        var isvalid = validator.validate();
 
        if (isvalid) {
post..
}
 

and it works fine if field is required but if its a mask with wrong entry it doesnt work.

Do you have some sample where the mask is checked on post?

Derek
Top achievements
Rank 1
 answered on 15 Jun 2015
1 answer
639 views

I'm using Kendo().DropDownList() with OptionLabel configured.

When trying to get selected item Text / Value, I'm getting incorrect values.

for example if I choose the first drop down option I'm getting the value of the option label.

if I choose the second option I'm getting the values of the first option.

 

@(Html.Kendo().DropDownList()
            .Name("SelectedSubjectId")
            .DataTextField("Text")
            .DataValueField("Value")
            .Filter("contains")
            .OptionLabel("Select Subject")
            .BindTo(Model.MailSubjectList)
            .Events(events =>
                    {
                        events.Select("onSelect");
                    })
        )

Javascript:

onSelect = function (e) {
    var dataItem = this.dataItem(e.item.index());

     // or even

    var selectedValue = this.value()

    var selectedText = this.text()

};

 

How can I get the correct selected value (Text / Value) ?

 

Thank you.

 

Plamen Lazarov
Telerik team
 answered on 15 Jun 2015
1 answer
103 views

To avoid sending thousands of records back to my control, I have set the minlength equal to 2. This has been working without issue until I upgraded Kendo UI from a 2014 version to the latest 2015 version. The filtering and control works but the first time you type to start filtering and you reach your minlength, the dropdown appears(as expected with the filtered data) but the text that was typed in the combobox gets erased. When you continue typing, no additional filtering happens until you reach the minlength, at which point the control behaves correctly. The only way for the problem to reoccur in that control again is to reload the page.

 

I have several pages that use this control. All of them now have this behavior but worked fine before the upgrade.

 

Thanks,

Scott Marcus

Plamen Lazarov
Telerik team
 answered on 12 Jun 2015
6 answers
656 views
Hello,
I tried to use the tooltip,in my test project,and it says object doesn't support property or method 'kendoToolTip" !
what do i need to work the tooltip?
the jquery is referenced.the kendo.mvc.dll is there...so?

A sample code is below

<div width="100" id="example">some text</div>
@(Html.Kendo().Tooltip()
.For("#example")
.Content("hello")
.Position(TooltipPosition.Top)
.Width(120)
)

Regards,
Daniel
Rosen
Telerik team
 answered on 12 Jun 2015
1 answer
88 views

Let' s say, there a mvc grid with a dropdown list inside it. The grid has three mode; view edit and add modes, in other words users are able to  view, edit, and add records.

The data source of this dropdown list changes dynamically depending on the modes; for example,

if in view mode, the ddl lists item1, item2, item3 item4, and item5,

if in Add mode, the ddl lists item2, item3.

if in Edit mode, the ddl lists item2, item5,

That means the ddl source from different linq queries depending on grid modes.

Is it possible to achieve it? Thanks

Boyan Dimitrov
Telerik team
 answered on 12 Jun 2015
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
DateTimePicker
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
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?