Telerik Forums
UI for ASP.NET MVC Forum
1 answer
254 views
I am developing an MVC 4 website for a customer and have run into an issue with the dropdownlist. 

I have a Grid, bound to my model, and I can see all the data (correctly) in the grid.
01.@(Html.Kendo().Grid((IEnumerable<MyModel>)ViewBag.Model)
02.                    .Name("Grid")
03.                    .Columns(columns =>
04.                    {
05.                        ..
06.                        removed for brevity
07.                        ..
08.                        columns.Command(command => { command.Edit(); command.Destroy(); });
09.                    })
10.                    .ToolBar(toolbar => toolbar.Create())
11.                    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditorTemplate"))
12.                    .Pageable()
13.                    .Sortable()
14.                    .Scrollable()
15.                    .DataSource(dataSource => dataSource
16.                        .Ajax()
17.                        .PageSize(20)
18.                        .Events(events => events.Error("error_handler"))
19.                        .Model(model => model.Id(m => m.recordID))
20.                        .Create(update => update.Action("Create", "Controller"))
21.                        .Update(update => update.Action("Update", "Controller"))
22.                        .Destroy(update => update.Action("Destroy", "Controller"))
23.                    )
24.                )
The above code loads the grid fine, I can trigger all the actions correctly, and they all work great.

My problem comes in when I edit a row, and the field I need to change is a DropDownList. For this particular issue, it is a list of States. We are using popup edit mode, and have a custom editor template.

This is the Editor Template code.
01.@(Html.Kendo().DropDownListFor(m => m.StateId)
02.        .Name("StateId")
03.        .DataTextField("StateName")
04.        .DataValueField("StateId")
05.        .DataSource(source =>
06.        {
07.            source.Read(read =>
08.            {
09.                read.Action("GetStatesList", "Controller");
10.            })
11.            .ServerFiltering(true);
12.        })
13.        .SelectedIndex(0)
14.        .OptionLabel("Select a State")
15.    )
The control successfully loads the states, and binds to the model, and shows the correct state value, if there is one provided. In our database, the StateId field is Nullable, and I think this is where the problems arise. 

For completeness, here is the controller function that populates the state list.
1.public JsonResult GetStatesList()
2.{
3.    var states = client.GetStates();
4.    return Json(states, JsonRequestBehavior.AllowGet);
5.}
the client.GetStates() returns an IEnumerable<State> collection.

NOTE: This exact same code works in a non-grid view in our MVC project.

Now, when the StateId is populated on load, it will display the correct state in the DropDownList. If I change this state and click the Update button on my popup editor, the Update Action is triggered, model.StateId = NewIDSelected and the change gets saved to the database. Now if the StateId is NULL from the database, obviously no state is selected, but now, if I select a state from the DropDownList, and click the Update button on my editor, the Update Action is not triggered, and no change is saved to the database.

To add to that, if I change any other field on the editor (say change or add the street address)  in addition to the State change (from null to a state value), the Update Action is correctly triggered, but the model.StateId = null.

As I stated before, this exact same scenario works perfectly on a view that does not use a grid at all (as a matter of fact the popup editor is an exact duplicate of that view).

Can anyone help me figure out how to fix this? We have got around it by using a plain HTML DropDownList, but it is ugly ugly... but it works.
Daniel
Telerik team
 answered on 03 Jun 2013
2 answers
121 views
The dropdownlist does not seem to find a value when I have a repeating character.

For example, I'm looking for a last name of "Allen".  I start typing "al" and the first occurrence with of a name beginning with "Al" is highlighted.  When I type the next "l", it jumps to the first occurrence of a name that begins with "L".

A regular html dropdownlist does not seem to behave this way.

I've tried fiddling with the delay option but it doesn't seem to help.

thanks
William Dunn
Top achievements
Rank 1
 answered on 03 Jun 2013
3 answers
279 views
I have grid with client detail template:

@(Html.Kendo().Grid<SalesOrderModel>()
      .Name("SalesOrders")
      .Columns(columns =>
          {
              columns.Bound(e => e.Number).Width(20).ClientTemplate(Html.ActionLink("#=Number#", "Edit", "SalesOrder", new { id = "#=Id#" }, null).ToHtmlString());
              columns.Bound(e => e.Status).Width(20);
              columns.Bound(e => e.ContractorName).Width(200);
              columns.Bound(e => e.CreatedDate).Width(40).Format("{0:d}");
          })            
      .ClientDetailTemplateId("itemsTemplate")
      .Pageable()
      .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .Read(read => read.Action("LoadData", "SalesOrder"))
                                    .PageSize(40)
      )
      .Sortable()
      .Filterable())
<script id="itemsTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<SalesOrderItem>()
            .Name("Items_#=Id#")
            .Columns(columns =>
            {
                columns.Bound(o => o.Position).Width(20);
                columns.Bound(o => o.Index).Width(100);
                columns.Bound(o => o.Name).Width(200);
                columns.Bound(o => o.Quantity).Width(20);
                columns.Bound(e => e.UnitOfMeasure).Width(20);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("LoadItems", "SalesOrder", new { salesOrderId = "#=Id#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>

and everything worked perfectly until now. I changed globalization section in web.config from
<globalization enableClientBasedCulture="true" culture="auto" /> 
to 
<globalization enableClientBasedCulture="false" culture="pl-PL" uiCulture="pl-PL" />
After this change exception is throwing by javascript "Invalid template ..."
Note that everything woks good except master-detail grid described above.

2Trace
Top achievements
Rank 1
 answered on 03 Jun 2013
2 answers
428 views
i was looking here
http://docs.kendoui.com/api/web/tooltip
after some posibilities to customize the tootip,but i did not find.
i would like to setup the dimensions of the container where is the text,also the color,and maybe the position or even the form of that poiting arrow.i noticed that by default is a gray color,and a perfect triangle as an arrow.

How can i customize the style for the tooltip?

Regards,
Daniel
Daniel
Top achievements
Rank 1
 answered on 03 Jun 2013
2 answers
158 views
Hi !

I've recently downloaded trial version of Kendo UI with wrappers for MVC. I'm developing simple application to test Kendo out and I'm stuck. What I want is for user to get text from Kendo Autocomplete, and when he clicks save button that text is added to database (so value is sent back to server - mvc controller ; I'm using EF 5.0 as ORM) and also that text is automatically showed on page without reloading it ! 
I've done the first part, but I'm stuck at showing text without reloading webpage.  I'm new in Javascript and jQuery but I believe this could be done using MVVM pattern. So my question is can I accomplish this using Kendo MVVM, and if I can, how ?

hyperN
Top achievements
Rank 1
 answered on 03 Jun 2013
4 answers
153 views
Hi My code below works fine in IE 10 , however it doesn't appear to work on page load event when using IE 8 or IE9. In brief I have a ListView that I bind manually upon page load and everytime something changes in the AutoComplete control. In IE9 and 8 the only thing that's's not working is being able to populating the ListView upon page load. I'm attempting to read the datasource of ListView to populate it. Look at my comment below in the Java Script section. As soon as I type something  in the AutoComplete text. then the listview populates and everything else works just fine. Maybe the sequence of where I have the .read() command should be moved to somewhere else to be able to refresh the ListView. But I'm not sure where. Any Ideas?

@model IEnumerable<HeatSeekerWeb.Models.Document>

<script type="text/x-kendo-tmpl" id="template">
    <div class="Document" id="template">
        <h3>#:Title#</h3>
        <a href="@Url.Content("~/Document/Download?url=#:Path#&fileName=#:FileName#")"><small>#:FileName#</small></a>        
        <p>#:Description#</p>
        <hr />
    </div>
</script>
<div id="divSearchDoc">
            @(Html.Kendo().AutoComplete()
        .Name("acDocuments")
        .Filter("startswith")
        .HtmlAttributes(new { style = "width:500px" })
        .Placeholder("Search Title...")
        .DataTextField("Title")
        .DataSource(source =>
                    {
                        source.Read(
                            read =>
                            {
                                read.Action("Get_Documents", "Document")
                                    .Data("onAdditionalData");
                            }
                            )
                            .ServerFiltering(true);
                    })
        .Events(events => events.DataBound("onDataBound").Select("onSelect").Change("onChange"))
        )
        @Html.ActionLink("Upload Document", "Create", "Document")
</div>
<div class="documents-sections">
    @(Html.Kendo().ListView<HeatSeekerWeb.Models.Document>()
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("template")
    .DataSource(dataSource =>
    {
        dataSource.Read(read => read.Action("Documents_Read", "Document").Data("getSelectedItems"));
        dataSource.PageSize(4);
    })
    .AutoBind(false)
    .Pageable()
)
</div>
<script>
    $(function () {
        // THIS LINE DOESN'T WORK on IE 8 and IE 9. No Problem in IE10
        $("#listView").data("kendoListView").dataSource.read();
    });

    function onAdditionalData() {
        return {
            text: $("#acDocuments").val()
        };
    }

    function getSelectedItems(e) {
        return { text: $("#acDocuments").val() };
    }

    function onDataBound(e) {
        $("#listView").data("kendoListView").dataSource.read();
    };
    function onChange() {
        $("#listView").data("kendoListView").dataSource.read();
    }

    function onSelect(e) {
        //var dataItem = this.dataItem(e.item.index());
        $("#listView").data("kendoListView").dataSource.read();
    }

</script>
Aaron
Top achievements
Rank 1
 answered on 31 May 2013
1 answer
238 views
Drop down list is continously showing the loading sign

I have the following model deliverable type

public partial class t_deliverable_type_mst
    {
        public t_deliverable_type_mst()
        {
            this.t_deliverable_item_mst = new HashSet<t_deliverable_item_mst>();
        }
    
        public int pk_d_type_id { get; set; }
        public string type { get; set; }
        public string logo { get; set; }
    
        public virtual ICollection<t_deliverable_item_mst> t_deliverable_item_mst { get; set; }
    }
I have create a kendo drop downlist as
@(Html.Kendo().DropDownList()
               .Name("dtype")
              .HtmlAttributes(new { style = "width: 200px" })
              
              .OptionLabel("Not working")
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetTypes", "deliverable");
                  })
                  .ServerFiltering(true);
                  
              })
             .DataTextField("type")
             .DataValueField("pk_d_type_id")
             .SelectedIndex(0)
             .Template("<img src=\"" + Url.Content("~/images/dtype_logo/") + "${data.logo}\" alt=\"${data.type}\" />" +
                         "<dl>" +
                          "<dt>Type:</dt><dd>${data.type}</dd>" +
                         "</dl>")
            )

this is the method in my controller
 public JsonResult GetTypes()
        {
            deliverableEntities deliv_ent = new deliverableEntities();
            JsonResult types = new JsonResult();

            var type_list = deliv_ent.t_deliverable_type_mst.ToList();

            types= Json(type_list, JsonRequestBehavior.AllowGet);
           
            return types;
        }

Petur Subev
Telerik team
 answered on 31 May 2013
4 answers
387 views
I have an ajax multiselect with autobind of false.  When returning to the page I would like my selected value(s) to display when the page loads, but they currently do not display until I click in the mulitselect.

Is there anything I can do to make this happen? 

I've attached a sample project.
@(Html.Kendo().MultiSelectFor(x => x.ReportOwner)
    .DataTextField("Name")
    .DataValueField("Pid")
    .DataSource(dataSource => dataSource
        .Read(read => read.Action("_RelatedEmployees", "AdvancedSearch"))
        .ServerFiltering(false)
        .Events(events => events.Error("onError"))
    )
    .AutoBind(false)
    .Placeholder("Select report owners...")
)
Georgi Krustev
Telerik team
 answered on 31 May 2013
13 answers
580 views
Here is our scenario:
We have a tree view control on the left with the list of document types and a grid control on the right that will list the documents (based on document type selection) with both inside a splitter control.When the users clicks on the document type, we want to recreate the grid because based on the document type the columns will change. 

For Example:
Document Type A will have columns Name, Type, Create Date, Attribute1, Attribute 2
Document Type B will have columns Name, Type, Create Date, Attribute6, Attribute 7, Attribute 8, Attribute 9
Document Type C will have columns Name, Type, Create Date, Attribute5

Problem:
When we click on the document type, the old column still exists and the new columns are not created but the data gets refreshed.

Questions:
1) What is the best option for our scenario?
2) Is there a way to destroy and recreate grid on demand?
3) If we have to destroy and recreate every time the users click on the document type, will that impact performance?

Here is  the code to create grid:
@model System.Data.DataTable

@(Html.Kendo().Grid(Model)
    .Name("DocumentGrid")
    .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            columns.Bound(column.ColumnName).Groupable(column.ColumnName != "Id").Title(column.Caption).Hidden(column.ColumnName == "Id");
        }
    })
    .Pageable()
    .Sortable()
    .Navigatable()
    //.Scrollable()
    .Filterable()
    .Groupable()
    .ColumnMenu()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
            {
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    model.Field(column.ColumnName, column.DataType);
                }                
            })
        .Read(read => read.Action("GetDocuments", "Controller"))
        .PageSize(20)
    )
)

Here is the code the create the tree view:
@helper RenderTreeView()
{
    @(Html.Kendo()
          .TreeView()
          .ExpandAll(true)
          .Name("treeview")
          .DataTextField("Text")
          .Events(events => events
                                  .Select("onChange"))
          .BindTo(Model, mappings =>
          {
              mappings.For<Test.Models.AllDocumentType>(binding => binding
                                                                                     .ItemDataBound((item, AllDocumentType) =>
                                                                                     {
                                                                                         item.Id = AllDocumentType.Id;                                                     
                                                                                         item.Text = AllDocumentType.Text;                        
                                                                                     })
                                                                                     .Children(AllDocumentType => AllDocumentType.DocumentTypes));
              mappings.For<Test.Models.DocumentType>(binding => binding
                                                                                  .ItemDataBound((item, DocumentType) =>
                                                                                  {
                                                                                      item.Id = DocumentType.Id.ToString();
                                                                                      item.Text = DocumentType.Name;
                                                                                  }));
          })                     
    )
}

Here is the onchange event:
function onChange(e) {
        var data = treeview.dataItem(e.node);
        
        $.post('@Url.Action("DocumentGrid", "Collector")', {
            id: data.id
        }, function (data) {
            var grid = $("#DocumentGrid").data("kendoGrid");
            grid.dataSource.read();            
        });
    }; 

Thanks,
Atanas Korchev
Telerik team
 answered on 30 May 2013
9 answers
773 views
Im trying to use a time picker without any luck.

@if (Model.OrderEndTime.HasValue)
     {
         @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15).Value(Model.OrderEndTime.Value.ToString("HH:mm tt"))
     }
     else
     {
         @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15)
     }
My problem is the picker is not getting bound to the value. The value is returned, I have check by 

@Html.LabelFor(m => m.OrderEndTime)
       @if (Model.OrderEndTime.HasValue)
       {
           @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15).Value(Model.OrderEndTime.Value.ToString("HH:mm tt"))
           <span>@Model.OrderEndTime.Value.ToString("HH:mm tt")</span>
       }
       else
       {
           @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15)
       }
adding the span and the value is correct. Do I need to do something else to get the time picker working?

Thank you!
Vladimir Iliev
Telerik team
 answered on 30 May 2013
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
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?